3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_sizes() { return [ "XXS" => 0, "XS" => 1, "S" => 2, "M" => 3, "L" => 4, "XL" => 5, "XXL" => 6, ]; } function sort_array_item_by_size($a, $b): int { $sizes = get_sizes(); // The next three lines really should include some error checking $size_a = explode("_", $a)[1]; $size_b = explode("_", $b)[1]; return $sizes[$size_a] <=> $sizes[$size_b]; } $your_array = ["GL001_XXL", "GL001_L", "GL001_XXS", "GL001_S"]; usort($your_array, "sort_array_item_by_size"); print_r($your_array);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.00.0120.00919.98
8.4.150.0020.00114.05
8.4.140.0130.01017.19
8.4.130.0080.00420.55
8.4.120.0130.00724.03
8.4.110.0050.00418.86
8.4.100.0110.00917.79
8.4.90.0070.00220.36
8.4.80.0110.00918.76
8.4.70.0070.00620.41
8.4.60.0100.01018.59
8.4.50.0100.00923.96
8.4.40.0060.00317.68
8.4.30.0100.01020.48
8.4.20.0130.00718.84
8.4.10.0000.00919.51
8.3.280.0110.00818.30
8.3.270.0160.00516.75
8.3.260.0120.00816.48
8.3.250.0080.01018.94
8.3.240.0060.00217.27
8.3.230.0160.00316.54
8.3.220.0120.00618.84
8.3.210.0080.01118.96
8.3.200.0050.00316.36
8.3.190.0120.00618.85
8.3.180.0120.00716.70
8.3.170.0070.01118.59
8.3.160.0110.00316.73
8.3.150.0150.00320.80
8.3.140.0180.00020.98
8.3.130.0040.00418.55
8.3.120.0070.00318.86
8.3.110.0030.00620.94
8.3.100.0060.00316.63
8.3.90.0110.00426.77
8.3.80.0060.00317.97
8.3.70.0120.00318.51
8.3.60.0000.01516.50
8.3.50.0060.01216.59
8.3.40.0130.00720.28
8.3.30.0140.00721.73
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0000.00826.16
8.2.290.0040.00320.33
8.2.280.0100.00418.39
8.2.270.0120.00617.31
8.2.260.0140.00420.12
8.2.250.0000.00818.28
8.2.240.0030.00617.39
8.2.230.0030.00722.58
8.2.220.0100.00324.06
8.2.210.0080.00326.77
8.2.200.0040.00418.54
8.2.190.0100.00716.75
8.2.180.0140.00716.75
8.2.170.0100.00718.86
8.2.160.0090.00922.96
8.2.150.0050.00225.66
8.2.140.0050.00224.66
8.2.130.0070.00026.16
8.2.120.0000.00820.80
8.2.110.0150.00620.54
8.2.100.0270.00319.11
8.2.90.0210.00618.95
8.2.80.0130.00418.75
8.2.70.0280.01018.50
8.2.60.0270.00018.82
8.2.50.0270.00718.68
8.2.40.0120.00618.92
8.2.30.0080.00318.69
8.2.20.0160.00018.82
8.2.10.0150.00418.98
8.2.00.0270.00018.85
8.1.330.0120.00621.92
8.1.320.0110.00816.20
8.1.310.0000.00916.95
8.1.300.0040.00419.62
8.1.290.0100.00030.84
8.1.280.0140.00025.92
8.1.270.0000.00723.99
8.1.260.0070.00026.35
8.1.250.0060.00328.09
8.1.240.0260.00018.60
8.1.230.0250.00718.70
8.1.220.0290.00618.45
8.1.210.0070.00319.89
8.1.200.0160.00018.60
8.1.190.0120.00318.42
8.1.180.0200.01218.35
8.1.170.0050.00918.47
8.1.160.0170.00618.53
8.1.150.0130.01720.25
8.1.140.0160.01318.39
8.1.130.0110.00618.45
8.1.120.0210.01518.57
8.1.110.0210.00618.45
8.1.100.0100.00718.59
8.1.90.0120.00418.52
8.1.80.0210.00718.69
8.1.70.0090.01518.76
8.1.60.0050.01418.68
8.1.50.0130.00718.57
8.1.40.0140.00018.92
8.1.30.0070.01118.78
8.1.20.0190.00618.78
8.1.10.0200.01318.55
8.1.00.0190.00718.58
8.0.300.0060.01217.65
8.0.290.0100.00517.82
8.0.280.0110.00017.81
8.0.270.0110.00517.80
8.0.260.0160.00017.63
8.0.250.0100.00517.87
8.0.240.0060.00917.59
8.0.230.0080.00418.34
8.0.220.0110.00317.84
8.0.210.0080.00817.83
8.0.200.0100.00717.82
8.0.190.0120.00417.79
8.0.180.0070.01117.71
8.0.170.0120.00317.88
8.0.160.0180.00017.86
8.0.150.0130.00517.89
8.0.140.0080.00817.72
8.0.130.0110.00218.22
8.0.120.0110.00717.83
8.0.110.0160.00017.85
8.0.100.0110.00517.89
8.0.90.0110.00417.92
8.0.80.0180.00017.63
8.0.70.0140.00017.86
8.0.60.0120.00417.64
8.0.50.0100.00617.79
8.0.30.0080.00417.91
8.0.20.0130.00317.95
8.0.10.0090.00618.05

preferences:
33.02 ms | 403 KiB | 5 Q