|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-28 10:23 UTC] 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) {
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 03:00:02 2025 UTC |
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.