Home > Article > Backend Development > Tips on using php array key names
This article mainly introduces the php array key name skills summary, analyzes the common usage skills of php array key names, and has certain reference value. Friends in need can refer to it
This article summarizes the techniques of PHP array key names in more detail. Share it with everyone for your reference. The specific analysis is as follows:
1. $arr[true] is equivalent to $arr[1]; $arr[false] is equivalent to $arr[0].
2. Using null as the key name is equivalent to creating or overwriting an $arr[null], which can be accessed using $arr[null] or $arr[""].
3. When using a number with a decimal point as the key name, the key name will automatically intercept the integer part as the key name. For example, $arr[123.45]=5, you can use $arr[123.45] or $arr[123] to obtain the key value; when traversing with foreach, $arr[123] is used.
4, $arr[]=5, the element will be added after the array $arr.
Note: The data type of the key name in the array is integer or stringtype
The above is the detailed content of Tips on using php array key names. For more information, please follow other related articles on the PHP Chinese website!