Bug #73617 [Com]: Array diff output is wrong.

From: Date: Tue, 29 Nov 2016 11:21:59 +0000
Subject: Bug #73617 [Com]: Array diff output is wrong.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205680@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73617&edit=1 ID: 73617 Comment by: hello at bweston dot me Reported by: hello at bweston dot me Summary: Array diff output is wrong. Status: Not a bug Type: Bug Package: Arrays related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Whoops, sorry, I thought assoc would be checking the key names. But you're right it does work. However still don't understand why the results wasn't correct in the first place as it is the values which have changed. Previous Comments: ------------------------------------------------------------------------ [2016-11-28 16:59:32] requinix@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php array_diff is not associative. Try array_diff_assoc instead. ------------------------------------------------------------------------ [2016-11-28 16:54:23] hello at bweston dot me Description: ------------ So I have the following ``` <?php var_dump(array_diff( [ 'q1' => true, 'q2' => true, 'q3' => false, 'q4' => false, ], [ 'q1' => false, 'q2' => false, 'q3' => false, 'q4' => false, ] )); ``` Which produces: (https://3v4l.org/WSs2s) ``` array(2) { ["q1"]=> bool(true) ["q2"]=> bool(true) } ``` Which is fine however with just one change it isn't seen. The following produces an empty array yet there is a change. (https://3v4l.org/DlnBr) ``` <?php var_dump(array_diff( [ 'q1' => true, 'q2' => true, 'q3' => false, 'q4' => false, ], [ 'q1' => false, 'q2' => true, 'q3' => false, 'q4' => false, ] )); ``` ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73617&edit=1

« previous php.bugs (#205680) next »