Bug #74313 [NEW]: Problem from array_diff function

From: Date: Sun, 26 Mar 2017 00:12:26 +0000
Subject: Bug #74313 [NEW]: Problem from array_diff function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208075@lists.php.net to get a copy of this message
From: dominik dot kolinski at gmail dot com Operating system: CentOS 7 PHP version: 5.6.30 Package: Arrays related Bug Type: Bug Bug description:Problem from array_diff function Description: ------------ Hello, i have a problem from array_diff function. I have a two dynamic arrays, which are a power from mysql. Which they have four different values: 4415, 4416,4417, and 4418. Unfortunately, using this feature (array_diff) has a bad output. (Return bad output) Function returns the full contents of the first array Instead of a difference. Please inform me what may be wrong. Regards, Dominik Koliński. This exemple topic in my .pl developer's forum: http://www.elektroda.pl/rtvforum/topic3323198.html?sid=c6056d33afbbf8b9e97f904d623082f4 Array_one : Array ( [0] => 4413 [1] => 4414 [2] => 13020 [3] => 13022 [4] => 4801 [5] => 4802 [6] => 4809 [7] => 11204 [8] => 14201 [9] => 14202 [10] => 14203 [11] => 12303 [12] => 12304 [13] => 10113 [14] => 10302 [15] => 10307 [16] => 4 [17] => 10404 [18] => 10502 [19] => 10701 [20] => 10704 [21] => 10801 [22] => 11006 [23] => 11201 [24] => 11305 [25] => 11310 [26] => 11605 [27] => 11702 [28] => 11705 [29] => 11707 [30] => 11803 } And Array second: Array ( [0] => 4413 [1] => 4414 [2] => 13020 [3] => 13022 [4] => 4801 [5] => 4802 [6] => 4809 [7] => 11204 [8] => 14201 [9] => 14202 [10] => 14203 [11] => 12303 [12] => 12304 [13] => 10113 [14] => 10302 [15] => 10307 [16] => 4 [17] => 10404 [18] => 10502 [19] => 10701 [20] => 10704 [21] => 10801 [22] => 11006 [23] => 11201 [24] => 11305 [25] => 11310 [26] => 11605 [27] => 11702 [28] => 11705 [29] => 11707 [30] => 11803 [31] => 4415 [32] => 4416 [33] => 4417 [34] => 4418 } Test script: --------------- This example from my code: $query_select_id_1 = mysql_query("SELECT id FROM tabela1 where id <> 0") or die("Zapytanie niepoprawne"); while($select_id_1 = mysql_fetch_assoc($query_select_id_1)){ $array_1[] = $select_id_1['id']; } $query_select_id_2 = mysql_query("SELECT id FROM tabela2 where id <> 0") or die("Zapytanie niepoprawne"); while($select_id_2 = mysql_fetch_assoc($query_select_id_2)){ $array_2[] = $select_id_2['id']; } $diff = array_diff($array_1, $array_2); print_r($diff); -- Edit bug report at https://bugs.php.net/bug.php?id=74313&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74313&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74313&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74313&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74313&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74313&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74313&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74313&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74313&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74313&r=support Expected behavior: https://bugs.php.net/fix.php?id=74313&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74313&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74313&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74313&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74313&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74313&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74313&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74313&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74313&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74313&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74313&r=mysqlcfg

« previous php.bugs (#208075) next »