3v4l.org

run code in 300+ PHP versions simultaneously
<?php $indexes = [ 26 => ["namespace" => "X\\Y\\Zed"], 9 => ["namespace" => "A\\B\\See"], 3 => ["namespace" => "A\\B\\Bee"], 38 => ["namespace" => "A\\B\\C\\Dee"], 51 => ["namespace" => "X\\Wye"], 16 => ["namespace" => "A\\Sea"], 12 => ["namespace" => "A\\Bees"], ]; uasort($indexes, static function (array $entry1, array $entry2): int { $ns1Parts = explode('\\', $entry1['namespace']); $ns2Parts = explode('\\', $entry2['namespace']); $ns1Length = count($ns1Parts); $ns2Length = count($ns2Parts); for ($i = 0; $i < $ns1Length && isset($ns2Parts[$i]); $i++) { $isLastPartForNs1 = $i === $ns1Length - 1; $isLastPartForNs2 = $i === $ns2Length - 1; if ($isLastPartForNs1 !== $isLastPartForNs2) { return $isLastPartForNs1 <=> $isLastPartForNs2; } $nsComparison = $ns1Parts[$i] <=> $ns2Parts[$i]; if ($nsComparison !== 0) { return $nsComparison; } } return 0; }); print_r($indexes);
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Array ( [38] => Array ( [namespace] => A\B\C\Dee ) [3] => Array ( [namespace] => A\B\Bee ) [9] => Array ( [namespace] => A\B\See ) [12] => Array ( [namespace] => A\Bees ) [16] => Array ( [namespace] => A\Sea ) [26] => Array ( [namespace] => X\Y\Zed ) [51] => Array ( [namespace] => X\Wye ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
70.26 ms | 408 KiB | 5 Q