View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
What is Array? An array is a data structure that stores one or more values in a single value. An array in PHP is actually an ordered map. It associates values to keys....
Types of Arrays Indexed Vs Associative Arrays The keys of an indexed array are integers, beginning at 0. Indexed arrays are used when you identify things by their position. $b = array('a', 'b', 'c');
Associative arrays have strings as keys and behave more like two-column tables. The first column is the key, which is used to access the value. $a = array( 'color' => 'red', 'taste' => 'sweet', 'shape' => 'round', 'name' => 'apple', 4 // key will be 0 );
Syntax An array can be created by array() . To construct an empty array, pass no arguments to array( ): $addresses = array( ); It takes as parameters any number of comma-separated key => value pairs. Example: $arr = array("foo" => "bar", 12 => true); echo $arr["foo"]; echo $arr; OR print_r($arr);