2. 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....
3. 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');
4. 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 );
5. 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[12]; OR print_r($arr);