3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$array = ["05h", "02h", "03c", "02s", "04h"]; //$array = ["05h", "02h", "03c", "02s", "03h"]; $array = ["03s", "02h", "03c", "02s", "03h"]; foreach ($array as $v) { $num = (int) $v; $counts[$num] = ($counts[$num] ?? 0) + 1; $map[$v] =& $counts[$num]; } var_dump($map); usort($array, fn($a, $b) => $map[$b] <=> $map[$a]); var_export($array);
Output for 8.1.32, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
array(5) { ["03s"]=> &int(3) ["02h"]=> &int(2) ["03c"]=> &int(3) ["02s"]=> &int(2) ["03h"]=> &int(3) } array ( 0 => '03s', 1 => '03c', 2 => '03h', 3 => '02h', 4 => '02s', )
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:
72.49 ms | 407 KiB | 5 Q