3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multidimArray = [ 'a' => [ 'boolean' => true, 'natString' => 'text10', 'object' => (object)['prop' => 2], 'float' => -.5, 'mixed' => [] ], 'b' => [ 'boolean' => true, 'natString' => 'text12', 'object' => (object)['prop' => 4], 'float' => 0, 'mixed' => null ], 'c' => [ 'boolean' => false, 'natString' => 'text100', 'object' => (object)['prop' => 9], 'float' => -.5, 'mixed' => false ], 'd' => [ 'boolean' => true, 'natString' => 'text1', 'object' => (object)['prop' => 9], 'float' => -5, 'mixed' => "\0" ], 'e' => [ 'boolean' => false, 'natString' => 'text2', 'object' => (object)['prop' => 2], 'float' => .5, 'mixed' => '' ] ]; //Sorting logic: boolean DESC (false = 0, true = 1, so trues before falses), float ASC uasort($multidimArray, fn($a, $b) => [$b['boolean'], $a['float']] <=> [$a['boolean'], $b['float']]); var_export($multidimArray); echo "\n---\n"; //Sorting logic: mixed ASC, object ASC, boolean ASC uasort($multidimArray, fn($a, $b) => [$a['mixed'], $a['object']->prop, $a['boolean']] <=> [$b['mixed'], $b['object']->prop, $b['boolean']]); var_export($multidimArray); echo "\n---\n"; //Sorting logic: property count of object ASC, iterability of mixed DESC, natString length ASC, natString ASC uasort($multidimArray, fn($a, $b) => [count(get_object_vars($a['object'])), is_iterable($a['mixed']), strlen($a['natString']), $a['natString']] <=> [count(get_object_vars($b['object'])), is_iterable($b['mixed']), strlen($b['natString']), $b['natString']] ); var_export($multidimArray);

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.4.20.0100.01019.75
8.4.10.0030.00619.67
8.3.150.0030.00616.77
8.3.140.0040.00416.95
8.3.130.0080.00018.60
8.3.120.0060.00919.28
8.3.110.0060.01020.94
8.3.100.0060.00324.06
8.3.90.0090.00926.77
8.3.80.0070.00319.36
8.3.70.0150.00018.68
8.3.60.0120.00618.55
8.3.50.0070.00624.48
8.3.40.0120.00318.80
8.3.30.0070.00718.71
8.3.20.0000.00820.86
8.3.10.0070.00020.38
8.3.00.0100.00320.71
8.2.260.0030.00618.39
8.2.250.0000.00816.81
8.2.240.0060.00317.32
8.2.230.0110.00722.58
8.2.220.0060.00337.54
8.2.210.0080.00026.77
8.2.200.0060.00318.88
8.2.190.0160.01216.63
8.2.180.0110.00718.29
8.2.170.0060.00922.96
8.2.160.0140.00322.12
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0000.00919.61
8.2.110.0030.00620.47
8.2.100.0000.01117.97
8.2.90.0040.00419.35
8.2.80.0040.00417.97
8.2.70.0060.00318.05
8.2.60.0030.00518.00
8.2.50.0050.00318.10
8.2.40.0000.00919.42
8.2.30.0040.00419.31
8.2.20.0040.00418.05
8.2.10.0000.01019.34
8.2.00.0030.00619.35
8.1.310.0070.00718.37
8.1.300.0090.00017.95
8.1.290.0060.00330.84
8.1.280.0070.01125.92
8.1.270.0030.00623.83
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00322.18
8.1.230.0040.00822.69
8.1.220.0050.00317.78
8.1.210.0060.00318.77
8.1.200.0060.00317.48
8.1.190.0000.00817.35
8.1.180.0050.00318.85
8.1.170.0060.00318.66
8.1.160.0040.00418.97
8.1.150.0000.00718.85
8.1.140.0030.00322.10
8.1.130.0030.00317.45
8.1.120.0000.00717.56
8.1.110.0080.00017.46
8.1.100.0000.00917.39
8.1.90.0040.00417.46
8.1.80.0040.00417.53
8.1.70.0040.00417.47
8.1.60.0030.00517.66
8.1.50.0000.00817.57
8.1.40.0050.00317.58
8.1.30.0030.00617.67
8.1.20.0030.00517.71
8.1.10.0030.00617.64
8.1.00.0000.01017.44
8.0.300.0000.00918.77
8.0.290.0000.00716.75
8.0.280.0030.00318.39
8.0.270.0080.00017.30
8.0.260.0030.00316.91
8.0.250.0000.00716.95
8.0.240.0000.00716.95
8.0.230.0030.00317.06
8.0.220.0000.00716.93
8.0.210.0070.00016.86
8.0.200.0030.00317.09
8.0.190.0040.00417.04
8.0.180.0050.00316.99
8.0.170.0050.00316.89
8.0.160.0000.00716.96
8.0.150.0040.00416.96
8.0.140.0050.00216.83
8.0.130.0000.00613.35
8.0.120.0050.00316.86
8.0.110.0000.00716.75
8.0.100.0050.00216.94
8.0.90.0030.00616.99
8.0.80.0130.00617.04
8.0.70.0000.00816.86
8.0.60.0000.00717.06
8.0.50.0040.00416.78
8.0.30.0110.00717.14
8.0.20.0200.00717.40
8.0.10.0030.00717.13
8.0.00.0070.01316.77
7.4.330.0000.00515.55
7.4.320.0040.00416.46
7.4.300.0030.00316.69
7.4.290.0000.00716.68
7.4.280.0050.00216.63
7.4.270.0000.00716.60
7.4.260.0070.00016.59
7.4.250.0070.00016.52
7.4.240.0030.00316.65
7.4.230.0080.00016.70
7.4.220.0050.00216.54
7.4.210.0070.01116.59
7.4.200.0040.00416.39
7.4.130.0100.00716.61
7.4.120.0170.00016.49
7.4.110.0180.00416.47
7.4.100.0150.00716.58
7.4.90.0060.01016.58
7.4.80.0040.01519.39
7.4.70.0150.00316.50
7.4.60.0120.00516.74
7.4.50.0030.01316.47
7.4.40.0070.01116.38
7.4.00.0100.01014.78
7.3.330.0030.00316.13
7.3.320.0050.00013.28
7.3.310.0000.00716.16
7.3.300.0040.00416.21
7.3.290.0080.00716.13
7.3.280.0170.01016.19
7.3.260.0100.01016.20
7.3.230.0060.01216.15
7.3.210.0100.00616.38
7.3.200.0000.01616.13
7.3.190.0060.00916.16
7.3.180.0120.00916.33
7.3.170.0070.01016.20
7.3.160.0120.00316.45
7.3.120.0070.00714.23
7.3.110.0100.00714.40
7.3.100.0070.00814.46
7.3.90.0070.01014.79
7.3.80.0100.00314.54
7.3.70.0080.00614.45
7.3.60.0110.00514.47
7.3.50.0120.00014.66
7.3.40.0100.00314.48
7.3.30.0030.01214.73
7.3.20.0080.00614.74
7.3.10.0100.00514.83
7.3.00.0070.00714.54
7.2.330.0140.00416.25
7.2.320.0140.01016.38
7.2.310.0100.00616.54
7.2.300.0140.01016.30
7.2.290.0060.01216.19
7.2.250.0070.00714.58
7.2.240.0040.01114.68
7.2.230.0070.01014.76
7.2.220.0110.00314.88
7.2.210.0060.00914.67
7.2.200.0120.00314.34
7.2.190.0100.00314.57
7.2.180.0030.01114.56
7.2.170.0090.00614.65
7.1.330.0100.00313.57
7.1.320.0070.00713.86
7.1.310.0250.00913.61
7.1.300.0000.01313.30
7.1.290.0000.01213.51
7.1.280.0140.00013.64
7.1.270.0090.00513.53
7.1.260.0090.00513.91

preferences:
34.95 ms | 403 KiB | 5 Q