#20319 [Opn->Bgs]: array_diff error with array contain NULL values.

From: Date: Sun, 10 Nov 2002 22:34:21 +0000
Subject: #20319 [Opn->Bgs]: array_diff error with array contain NULL values.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-24460@lists.php.net to get a copy of this message
ID: 20319 Updated by: venaas@php.net Reported By: yanik@lecourriel.com -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux RedHat PHP Version: 4.2.2 New Comment: In PHP '' == NULL, so I think it's correct that array_diff() treats them the same. It removes all elements from the 1st argument that are equal (normal PHP equality) to any element in the other arguments. Previous Comments: ------------------------------------------------------------------------ [2002-11-08 14:36:00] yanik@lecourriel.com This work !!! ------------------------------------------------ $arr1 = array('Color' => ''); $arr2 = array('Img1' => 3, 'Img2' => 2, 'Color' => 'Yellow'); print_r(array_diff($arr1, $arr2)); Return : Array ( [Color] => ) This not work!!! ------------------------------------------------ $arr1 = array('Color' => ''); $arr2 = array('Img1' => NULL, 'Img2' => 2, 'Color' => 'Yellow'); print_r(array_diff($arr1, $arr2)); Return : Array () This work !!! ------------------------------------------------ $arr1 = array('Color' => 'Red'); $arr2 = array('Img1' => NULL, 'Img2' => 2, 'Color' => 'Yellow'); print_r(array_diff($arr1, $arr2)); When your array contain NULL value the array diff does not recognize that Color is different. But if "Color" is not empty and different in both array the return value is corect. Sorry for my english ! Yanik ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20319&edit=1

« previous php.bugs (#24460) next »