<?php
class Profile { public $n; };
$p1 = new Profile(); $p1->n = "Profile #1";
$p2 = new Profile(); $p2->n = "Profile #2";
$p3 = new Profile(); $p3->n = "Profile #3";
$a1 = array($p1, $p2);
$a2 = array($p2, $p3);
var_dump(array_udiff($a1, $a2, function ($a, $b) { var_dump($a->n, $b->n, $a === $b); return $a === $b ? 0 : 1; }));
- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 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
- string(10) "Profile #1"
string(10) "Profile #2"
bool(false)
string(10) "Profile #2"
string(10) "Profile #3"
bool(false)
string(10) "Profile #2"
string(10) "Profile #3"
bool(false)
string(10) "Profile #2"
string(10) "Profile #2"
bool(true)
string(10) "Profile #2"
string(10) "Profile #1"
bool(false)
array(1) {
[0]=>
object(Profile)#1 (1) {
["n"]=>
string(10) "Profile #1"
}
}
- 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
string(10) "Profile #1"
string(10) "Profile #2"
bool(false)
string(10) "Profile #2"
string(10) "Profile #3"
bool(false)
string(10) "Profile #2"
string(10) "Profile #3"
bool(false)
string(10) "Profile #2"
string(10) "Profile #2"
bool(true)
string(10) "Profile #2"
string(10) "Profile #1"
bool(false)
array(1) {
[0]=>
object(Profile)#1 (1) {
["n"]=>
string(10) "Profile #1"
}
}
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
- string(10) "Profile #2"
string(10) "Profile #1"
bool(false)
string(10) "Profile #3"
string(10) "Profile #2"
bool(false)
string(10) "Profile #1"
string(10) "Profile #2"
bool(false)
string(10) "Profile #1"
string(10) "Profile #3"
bool(false)
string(10) "Profile #1"
string(10) "Profile #2"
bool(false)
array(2) {
[0]=>
object(Profile)#1 (1) {
["n"]=>
string(10) "Profile #1"
}
[1]=>
object(Profile)#2 (1) {
["n"]=>
string(10) "Profile #2"
}
}
preferences:
150.94 ms | 402 KiB | 184 Q