Home  >  Article  >  Backend Development  >  What does => mean in php array

What does => mean in php array

小老鼠
小老鼠Original
2023-06-16 15:56:562112browse

In php array => represents the connector between the array key name and the element. Simply put, the => symbol is used to separate keys and values. The left side represents the key and the right side represents the value.

What does => mean in php array

The operating environment of this tutorial: Windows 10 system, PHP8.1.3 version, Dell G3 computer.

=> in php is generally used as a connector between array keys and elements. Simply put, the => symbol is used to separate keys and values. The left side represents the key and the right side represents the value.

For example:

$arr = array(
'a'=>'123',
'b'=>'456'
);
foreach($arr as $key=>$val){
//$key是数组键名
//$val是数组键名对应的值
}

Commonly used array operators

: Merge arrays. If the key names are the same, only the keys of the left array will be displayed. Value pair;

==: Compare the key name of the array and the corresponding key value. If they are the same, return true, otherwise return false;

===: Compare the key name and the corresponding key value. Whether the key values ​​and key value types are the same, and the order must be the same;

!=: Compare the key names of the array and the corresponding key values ​​​​are different;

!==: Compare the array key names Whether the key name and the corresponding key value and key value type are different, or the order is different;

<>: The effect is the same as !=

The above is the detailed content of What does => mean in php array. 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