[php-src] Issue #13722: array-uintersect don't work on both side
| From: | houssemz | Date: | Fri, 15 Mar 2024 11:29:19 +0000 |
| Subject: | [php-src] Issue #13722: array-uintersect don't work on both side | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246587@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13722
Author: houssemz
### Description
The following code:
Please see https://3v4l.org/3gVeB
```php
<?php
$arr1 = ['2b', 'b6', '5a'];
$arr2 = ['5A']; // even for $arr2 = ['5a']
$u1 = array_uintersect($arr1, $arr2, function (string $a, string $b) {
var_dump($a. ' == '. $b);
return (int)($a == $b);
});
print_r($u1);
$u2 = array_uintersect($arr2, $arr1, function (string $a, string $b) {
var_dump($a. ' == '. $b);
return (int)($a == $b);
});
print_r($u2);
```
Resulted in this output:
```
string(8) "2b == b6"
string(8) "b6 == 5a"
string(8) "2b == 5A"
string(8) "2b == b6"
string(8) "b6 == 5a"
Array
(
[0] => 2b
[1] => b6
[2] => 5a
)
string(8) "2b == b6"
string(8) "b6 == 5a"
string(8) "5A == 2b"
Array
(
[0] => 5A
)
```
But I expected this output instead:
```
string(8) "2b == b6"
string(8) "b6 == 5a"
string(8) "2b == 5A"
string(8) "2b == b6"
string(8) "b6 == 5a"
Array
(
[2] => 5a
)
string(8) "2b == b6"
string(8) "b6 == 5a"
string(8) "5A == 2b"
Array
(
[0] => 5A
)
```
### PHP Version
PHP 8.3.3
### Operating System
macOS Sonoma 14.2.1