40 likes | 140 Views
PHP5. Array concepts. Basic Array. If you do not set the key when you create an array the initial value is 0 and then it auto increments $ arr [] = “First index”; $ arr [] = “Second index”; print($arr[1]); // is “Second index” print($arr[0]); // is “First index”. Array Unordered.
E N D
PHP5 Array concepts
Basic Array • If you do not set the key when you create an array the initial value is 0 and then it auto increments $arr[] = “First index”; $arr[] = “Second index”; print($arr[1]); // is “Second index” print($arr[0]); // is “First index”
Array Unordered • You can specifically give an array key and not do this in a specific order $arr[12] = “First index”; $arr[9] = “Second index”; print($arr[9]); // is “Second index” print($arr[12]); // is “First index”
Associative Array • You can specifically give an array key a name $arr[‘name_first’] = “Ray”; $arr[‘name_last’] = “Gubala”; print($arr[‘name_first’]); // is “Gubala” print($arr[‘name_last’]); // is “Ray”