<?php
class Role
{
public $public;
protected $protected;
private $private;
public function __construct($prop)
{
$this->public = $prop;
$this->protected = $prop;
$this->private = $prop;
}
}
$test = [(new Role(false)), (new Role(1)), (new Role(null)), (new Role("1")), (new Role(2)), (new Role(0))];
var_export(
array_unique($test, SORT_REGULAR)
);
echo "\n---\n";
var_export(
array_filter(
$test,
fn($o, $k) => array_search($o, $test, true) === $k,
ARRAY_FILTER_USE_BOTH
)
);
preferences:
29.78 ms | 407 KiB | 5 Q