3v4l.org

run code in 300+ PHP versions simultaneously
<?php $indexes = [ 'id_1_2_3_0' => 1, 'id_1_2_-0.25_0' => 2, 'id_1_2_1.75_0' => 3, 'id_1_2_-4_0' => 4, 'id_1_2_0_0' => 5, 'id_1_2_-1.25_0' => 6, ]; uksort($indexes, fn($a, $b) => explode('_', $a) <=> explode('_', $b)); var_export($indexes);
Output for 7.4.4 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array ( 'id_1_2_-4_0' => 4, 'id_1_2_-1.25_0' => 6, 'id_1_2_-0.25_0' => 2, 'id_1_2_0_0' => 5, 'id_1_2_1.75_0' => 3, 'id_1_2_3_0' => 1, )
Output for 7.3.0 - 7.3.33
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')' in /in/WGL15 on line 12
Process exited with code 255.
Output for 7.1.25 - 7.1.31, 7.2.0 - 7.2.33
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')' in /in/WGL15 on line 12
Process exited with code 255.

preferences:
107.39 ms | 1471 KiB | 4 Q