Bug #78164 [Opn->Nab]: array_diff_key won't return diff while it shoud in a very specific case

From: Date: Fri, 14 Jun 2019 16:04:35 +0000
Subject: Bug #78164 [Opn->Nab]: array_diff_key won't return diff while it shoud in a very specific case
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221315@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78164&edit=1 ID: 78164 Updated by: requinix@php.net Reported by: joseph42379 at gmail dot com Summary: array_diff_key won't return diff while it shoud in a very specific case -Status: Open +Status: Not a bug Type: Bug -Package: Unknown/Other Function +Package: *General Issues Operating System: Mac OS PHP Version: 7.1Git-2019-06-14 (snap) 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 https://www.php.net/manual/en/function.array-diff-key.php > Compares the keys from array1 against the keys from array2 and returns the difference. This > function is like > array_diff() except the comparison is done on the keys instead of the values. > Returns an array containing all the entries from array1 whose keys are absent from all of the > other arrays. Previous Comments: ------------------------------------------------------------------------ [2019-06-14 15:56:11] joseph42379 at gmail dot com Description: ------------ Turns out if the first argument(array) provided is smaller than the second one, it always return the empty array. Test script: --------------- <? var_dump( array_diff_key( [ 'a'=>1, ], [ 'a'=>1, 'b'=>1 ] ) ); Expected result: ---------------- array(0) { ["b"]=> int(1) } Actual result: -------------- array(0) { } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78164&edit=1

« previous php.bugs (#221315) next »