<?php
$array1 =
array(
array('ur_user_id'=> 1,'ur_fname'=>'PerA','ur_lname'=>'SonA'),
array('ur_user_id'=> 2,'ur_fname'=>'PerB','ur_lname'=>'SonB'),
array('ur_user_id'=> 3,'ur_fname'=>'PerC','ur_lname'=>'SonC'),
);
$array2 =
array(
array('ur_user_id' => 5,'ur_code' => 'EE','ur_user_role' => 'testE'),
array('ur_user_id' => 4,'ur_code' => 'DD','ur_user_role' => 'testD'),
array('ur_user_id' => 6,'ur_code' => 'FF','ur_user_role' => 'testF'),
array('ur_user_id' => 3,'ur_code' => 'CC','ur_user_role' => 'testC'),
array('ur_user_id' => 1,'ur_code' => 'AA','ur_user_role' => 'testA'),
array('ur_user_id' => 2,'ur_code' => 'BB','ur_user_role' => 'testB'),
);
usort($array2,function($a,$b){
return strnatcmp($a['ur_user_id'],$b['ur_user_id']);
});
print_r(array_uintersect($array2,$array1,function($a,$b){
return strnatcmp($a['ur_user_id'],$b['ur_user_id']);
}));
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- Array
(
[0] => Array
(
[ur_user_id] => 1
[ur_code] => AA
[ur_user_role] => testA
)
[1] => Array
(
[ur_user_id] => 2
[ur_code] => BB
[ur_user_role] => testB
)
[2] => Array
(
[ur_user_id] => 3
[ur_code] => CC
[ur_user_role] => testC
)
)
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[0] => Array
(
[ur_user_id] => 1
[ur_code] => AA
[ur_user_role] => testA
)
[1] => Array
(
[ur_user_id] => 2
[ur_code] => BB
[ur_user_role] => testB
)
[2] => Array
(
[ur_user_id] => 3
[ur_code] => CC
[ur_user_role] => testC
)
)
preferences:
172.06 ms | 403 KiB | 192 Q