[英]Equality of PHP associative arrays
Quick question about PHP associative arrays.关于 PHP 关联数组的快速问题。
Say there are two arrays:假设有两个数组:
$A = array("AAA" => "45", "FFF" => "108", "GGG" => "15");
and和
$B = array("FFF" => "108", "GGG" => "15", "AAA" => "45");
Are these arrays equal?这些数组相等吗? Does the position of an entry in associative arrays matter?
关联数组中条目的位置是否重要?
According to PHP official document:根据PHP官方文档:
http://php.net/manual/en/language.operators.array.php http://php.net/manual/en/language.operators.array.php
$a == $b
TRUE if $a
and $b
have the same key/value pairs. $a == $b
如果$a
和$b
具有相同的键/值对, $b
TRUE。
$a === $b
TRUE if $a
and $b
have the same key/value pairs in the same order and of the same types. $a === $b
如果$a
和$b
具有相同顺序和相同类型的相同键/值对, $a === $b
TRUE。
$A=array ("AAA"=>"45", "FFF"=>"108", "GGG"=>"15");
$B=array ("FFF"=>"108", "GGG"=>"15", "AAA"=>"45");
var_dump($A==$B);
bool(true)
布尔(真)
var_dump($A===$B);
bool(false)
布尔(假)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.