3v4l.org

run code in 500+ PHP versions simultaneously
<?php function cmp_strict(mixed $a, mixed $b): int { if ($a === $b) return 0; $typeA = gettype($a); $typeB = gettype($b); if ($typeA === $typeB) { return match($typeA){ "string" => strcmp($a, $b), "object" => spl_object_id($a) <=> spl_object_id($b), default => $a <=> $b, }; } else { return $typeA <=> $typeB; } } $data = [ 3, 4, 1, "a", "0", "x", 0, 1, 4, STDIN, STDERR, STDOUT, [3], [[4]], [], (object)['a'=>true], new stdClass ]; usort($data, 'cmp_strict'); var_dump($data);

preferences:
22.84 ms | 479 KiB | 4 Q