Edit report at https://bugs.php.net/bug.php?id=61540&edit=1

 ID:                 61540
 Updated by:         [email protected]
 Reported by:        pfraszczak at power dot com dot pl
 Summary:            array_diff has problem when in second array is entry
                     with null value
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Arrays related
 Operating System:   ubuntu
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------
[2012-03-29 04:24:54] reeze dot xia at gmail dot com

Hi pfraszczak:
    This is NOT a bug. 
    because "" == NULL  => TRUE. 

if we change the test script to :

$a = array('street'=>'not-null-equal-value','number'=>'n1');
$b = array('street'=>'b1','number'=>'n1','test'=>null);
var_dump(array_diff($a,$b));

you will get the right result.

------------------------------------------------------------------------
[2012-03-28 10:27:18] pfraszczak at power dot com dot pl

Changed package

------------------------------------------------------------------------
[2012-03-28 10:23:25] pfraszczak at power dot com dot pl

Description:
------------
I notice that array_diff return empty array when in second array we have entry 
with null value. When i removed entry with test key - everything works fine.

Moreover it seems that null values in $a array don't brake array_diff

Test script:
---------------
$a = array('street'=>'','number'=>'n1');
$b = array('street'=>'b1','number'=>'n1','test'=>null);
var_dump(array_diff($a,$b));


Expected result:
----------------
array(1) {
  ["street"]=>
  string(0) ""
}

Actual result:
--------------
array(0) {
}



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61540&edit=1

Reply via email to