Doc #65934 [Opn->Nab]: Comparing arrays

From: Date: Tue, 22 Oct 2013 11:48:40 +0000
Subject: Doc #65934 [Opn->Nab]: Comparing arrays
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10519@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 Updated by: daverandom@php.net Reported by: info at pkrules dot in Summary: Comparing arrays -Status: Open +Status: Not a bug 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: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2013-10-21 06:36:48] gabri dot ns at gmail dot com $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. ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#10519) next »