3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types = 1); // lint >= 8.1 final class Foo implements \Stringable { private function __construct(public readonly string $value) { } public static function fromString(string $string): self { return new self($string); } public function __toString(): string { return $this->value; } } function userlandComparator(string $a, string $b): int { return strnatcasecmp($a, $b); } $options = [ Foo::fromString('c'), Foo::fromString('b'), Foo::fromString('a'), ]; uasort($options, 'userlandComparator'); var_dump($options);

preferences:
79.99 ms | 2764 KiB | 5 Q