The key in the php array is a unique identifier. In a PHP array, each element is distinguished by a special identifier, which is called a key (also called a subscript); the key of the array is unique and will not exist repeatedly, even if When two identical key names are declared, the value of the latter key name will overwrite the value of the previous key name.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php array middle key (subscript ) is a unique identifier.
Each element of an array is distinguished by a special identifier called a key (also called a subscript).
Each entity in the array contains two items, namely key and value. The corresponding array elements can be obtained by key value. These keys can be numeric keys or association keys.
In the php array, the key name (key) is unique and will not exist repeatedly.
<?php header('content-type:text/html;charset=utf-8'); $arr=array("id"=>1,"name"=>"李华","age"=>23,"id"=>2,"name"=>"小明"); var_dump($arr); ?>
It can be seen that even if two identical key names are declared, the value of the later declared key name will overwrite the value of the previous key name. PHP array key names are unique.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Are keys in php arrays unique identifiers?. For more information, please follow other related articles on the PHP Chinese website!