php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65934 Comparing arrays
Submitted: 2013-10-21 06:28 UTC Modified: 2013-10-22 11:48 UTC
From: info at pkrules dot in Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.4.21 OS: windows 8 pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: info at pkrules dot in
New email:
PHP Version: OS:

 

 [2013-10-21 06:28 UTC] 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)
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-21 06:36 UTC] 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-22 11:48 UTC] daverandom@php.net
-Status: Open +Status: Not a bug
 [2013-10-22 11:48 UTC] daverandom@php.net
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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 02:01:29 2024 UTC