Does the array of php only support numeric subscripts?
This article mainly introduces whether the array of php only supports digital subscript, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.
No, the subscript (index value) of the php array can be a string or a number. An array with a subscript of a string is an associative array, which is an array with a special index; an array with a subscript of a number is an indexed array, whose subscript value must be an integer, starting with 0, and so on.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In PHP, the subscript (index value) of an array can be a string or a number.
An array subscribed to a string is an associative array
An array with a subscript of numbers is an indexed array
Indexed array
The indexed array stores a series of organized single or multiple values, each of which can be accessed by using an unsigned integer value. The key of the indexed array is an integer, starting at 0, and so on.
Associative array
An associative array is an array with a special index. Use a string or other type of value (except NULL) to index it.
In fact, the difference between an associative array and an indexed array is only in the key value, the key value of the associative array is a string and is artificially specified.
Thank you for reading this article carefully. I hope the article "does the array of php only support digital subscript" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!