#25164 [Com]: array_diff issue

From: Date: Mon, 25 Aug 2003 18:09:23 +0000
Subject: #25164 [Com]: array_diff issue
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-46590@lists.php.net to get a copy of this message
ID: 25164 Comment by: linuxfool at Hotmail dot com Reported By: linuxfool at hotmail dot com Status: Bogus Bug Type: Scripting Engine problem Operating System: * PHP Version: 4.3.2 New Comment: Crack Prevails once again... Previous Comments: ------------------------------------------------------------------------ [2003-08-24 11:07:34] sniper@php.net Actually this is bogus. From manual: "array_diff() returns an array containing all the values of array1 that are not present in any of the other arguments." In your example, 30 is present in the $array2. ------------------------------------------------------------------------ [2003-08-24 11:03:13] sniper@php.net Simpler script: <?php $array1 = array (2,2); $array2 = array (1,2); print_r($array1); print_r($array2); print_r(array_diff($array1,$array2)); ?> Output: Array ( [0] => 2 [1] => 2 ) Array ( [0] => 1 [1] => 2 ) Array ( ) ------------------------------------------------------------------------ [2003-08-20 02:06:37] linuxfool at hotmail dot com Description: ------------ See Code. Thanks for your time. Reproduce code: --------------- echo "<pre>"; echo "RUNNING PHP VER 4.2.2 ON RH 9\n"; $array1 = array (1=>9,2=>10,3=>5,4=>54,5=>30,6=>1,7=>22,8=>22,9=>111,10=>110,11=>30); $array2 = array (1=>9,2=>10,3=>5,4=>54,5=>30,6=>1,7=>22,8=>22,9=>111,10=>110,11=>112); print_r($array1); print_r($array2); print_r(array_diff($array1,$array2)); echo "If the last value in array1 (30) is changed to anything other then 30(that i am aware of) array_diff works right.\nHave I been smoking too much crack again?\n"; echo "</pre>"; ?> Expected result: ---------------- RUNNING PHP VER 4.2.2 ON RH 9 Array ( [1] => 9 [2] => 10 [3] => 5 [4] => 54 [5] => 30 [6] => 1 [7] => 22 [8] => 22 [9] => 111 [10] => 110 [11] => 30 ) Array ( [1] => 9 [2] => 10 [3] => 5 [4] => 54 [5] => 30 [6] => 1 [7] => 22 [8] => 22 [9] => 111 [10] => 110 [11] => 112 ) Array ( [11] => 30 ) If the last value in array1 (30) is changed to anything other then 30(that i am aware of) it works right. Have I been smoking too much crack again? Actual result: -------------- RUNNING PHP VER 4.2.2 ON RH 9 Array ( [1] => 9 [2] => 10 [3] => 5 [4] => 54 [5] => 30 [6] => 1 [7] => 22 [8] => 22 [9] => 111 [10] => 110 [11] => 30 ) Array ( [1] => 9 [2] => 10 [3] => 5 [4] => 54 [5] => 30 [6] => 1 [7] => 22 [8] => 22 [9] => 111 [10] => 110 [11] => 112 ) Array ( ) If the last value in array1 (30) is changed to anything other then 30(that i am aware of) it works right. Have I been smoking too much crack again? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25164&edit=1

« previous php.bugs (#46590) next »