Home>Article>Backend Development> The difference between php associative array and index array
In PHP, an array is a collection of a series of data, forming an operable whole. Each data is an element, and the element contains a key name and a key value.
The difference between index array and associative array is distinguished by key name
1. Index array(Recommended learning:PHP video tutorial)
'; echo '数组 $arr 中的,键名为2的键值为:'.$arr[2]; ?>
The results show:
2. Associative array
'苹果','Banana' => '香蕉','Orange' => '橘子','Plum' => '李子','Strawberry' => '草莓'); print_r($arr1); ?>
The result shows:
Arrays with numbers as key names are generally called index arrays and associative arrays The key values are strings and are artificially specified.
The above is the detailed content of The difference between php associative array and index array. For more information, please follow other related articles on the PHP Chinese website!