[php-src] Issue #15050: array_diff weirdness

From: Date: Sun, 21 Jul 2024 04:46:12 +0000
Subject: [php-src] Issue #15050: array_diff weirdness
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247332@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/15050 Author: shieldz80 ### Description The following code: ```php <?php $arr1 = ['a' => null, 'b' => null]; $arr2 = ['a' => 1, 'b' => null]; var_dump(array_diff($arr1, $arr2)); ``` Resulted in this output: ``` array(0) { } ``` But I expected this output instead: ``` array(1) { ["a"]=> NULL } ``` On the other hand ```php <?php $arr1 = ['a' => null]; $arr2 = ['a' => 1]; var_dump(array_diff($arr1, $arr2)); ``` Results in the expected ``` array(1) { ["a"]=> NULL } ``` So it seems that the weird behavior occurs only when there are multiple null values in the array. ### PHP Version PHP 8.3.4 (cli) ### Operating System Alpine Linux v3.19

« previous php.bugs (#247332) next »