Index array
Arrays with numbers as key names are generally called index arrays. An array whose keys are represented by strings is an associative array that will be introduced below. The keys of the index array are integers and start from 0 and so on.
Index array initialization example:
Copy after login
Running result
Array ( [0] => 苹果 [1] => 香蕉 )
Associative array
In fact, associative array The difference from the index array is only in the key value. The key value of the associative array is a string, and it is an artificial regulation, for example:
'橘子'); echo $fruit['orange']; ?>
The above is the detailed content of What are the two types of php arrays based on index?. For more information, please follow other related articles on the PHP Chinese website!