Doc #65934 [Com]: Comparing arrays
| From: | gabri dot ns at gmail dot com | Date: | Mon, 21 Oct 2013 06:36:48 +0000 |
| Subject: | Doc #65934 [Com]: Comparing arrays | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10509@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65934&edit=1
ID: 65934
Comment by: gabri dot ns at gmail dot com
Reported by: info at pkrules dot in
Summary: Comparing arrays
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: windows 8 pro
PHP Version: 5.4.21
Block user comment: N
Private report: N
New Comment:
$a == $b Equality TRUE if $a and $b have the same key/value pairs.
$a === $b Identity TRUE if $a and $b have the same key/value pairs
in the same order and of the same types.
this is not a bug.
$a=array(22,44);
$b=array(44,22);
have the same meaning as
$a=array(0=>22,1=>44);
$b=array(0=>44,1=>22);
they don't have the same key/value pairs.
Previous Comments:
------------------------------------------------------------------------
[2013-10-21 06:28:53] info at pkrules dot in
Description:
------------
http://www.php.net/manual/en/language.operators.array.php
http://www.php.net/manual/en/language.operators.array.php#113026
Test script:
---------------
http://www.php.net/manual/en/language.operators.array.php#113026
<?php
$a=array(22,44);
$b=array(44,22);
var_dump($a==$b);//bool(false)
echo "<br />";
var_dump($a===$b);//bool(false)
echo "<br />";
$a=array("ab","ba");
$b=array("ba","ab");
var_dump($a==$b);//bool(false)
echo "<br />";
var_dump($a===$b);//bool(false)
?>
Expected result:
----------------
<?php
$a=array(22,44);
$b=array(44,22);
var_dump($a==$b);//bool(true)
echo "<br />";
var_dump($a===$b);//bool(false)
echo "<br />";
$a=array("ab","ba");
$b=array("ba","ab");
var_dump($a==$b);//bool(true)
echo "<br />";
var_dump($a===$b);//bool(false)
?>
Actual result:
--------------
<?php
$a=array(22,44);
$b=array(44,22);
var_dump($a==$b);//bool(false)
echo "<br />";
var_dump($a===$b);//bool(false)
echo "<br />";
$a=array("ab","ba");
$b=array("ba","ab");
var_dump($a==$b);//bool(false)
echo "<br />";
var_dump($a===$b);//bool(false)
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65934&edit=1