Home >Backend Development >PHP Problem >Are keys in php arrays unique identifiers?

Are keys in php arrays unique identifiers?

青灯夜游
青灯夜游Original
2022-06-01 20:53:152862browse

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.

Are keys in php arrays unique identifiers?

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.

Are keys in php arrays unique identifiers?

In the php array, the key name (key) is unique and will not exist repeatedly.

<?php
header(&#39;content-type:text/html;charset=utf-8&#39;);   
$arr=array("id"=>1,"name"=>"李华","age"=>23,"id"=>2,"name"=>"小明");
var_dump($arr);
?>

Are keys in php arrays unique identifiers?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn