Bug #73617 [Opn->Nab]: Array diff output is wrong.

From: Date: Mon, 28 Nov 2016 16:59:34 +0000
Subject: Bug #73617 [Opn->Nab]: Array diff output is wrong.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205674@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 Updated by: requinix@php.net Reported by: hello at bweston dot me Summary: Array diff output is wrong. -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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 (#205674) next »