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, function($a, $b) { return [$b['boolean'], $a['float']] <=> [$a['boolean'], $b['float']]; }); var_export($multidimArray); echo "\n---\n"; //Sorting logic: mixed ASC, object ASC, boolean ASC uasort($multidimArray, function($a, $b) { return [$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, function($a, $b) { return [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); echo "\n---\n";

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.0030.01919.46
8.4.10.0160.00319.47
8.3.150.0140.00417.04
8.3.140.0150.00416.80
8.3.130.0080.00318.55
8.3.120.0080.00818.91
8.3.110.0090.00020.94
8.3.100.0060.00324.06
8.3.90.0080.00026.77
8.3.80.0100.00017.97
8.3.70.0060.00916.63
8.3.60.0040.01118.55
8.3.50.0050.00924.62
8.3.40.0120.00918.89
8.3.30.0120.00318.71
8.3.20.0050.00320.54
8.3.10.0080.00022.10
8.3.00.0070.00022.43
8.2.260.0040.00419.23
8.2.250.0110.00718.56
8.2.240.0000.00917.25
8.2.230.0090.00022.58
8.2.220.0050.00537.54
8.2.210.0120.00626.77
8.2.200.0030.00716.75
8.2.190.0070.01116.63
8.2.180.0060.01018.54
8.2.170.0060.00922.96
8.2.160.0090.00622.16
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00726.16
8.2.110.0060.00321.12
8.2.100.0040.00817.84
8.2.90.0000.00817.95
8.2.80.0000.00817.97
8.2.70.0060.00317.75
8.2.60.0000.00817.63
8.2.50.0040.00418.10
8.2.40.0070.00419.42
8.2.30.0060.00319.35
8.2.20.0070.00018.27
8.2.10.0060.00219.50
8.2.00.0110.00118.63
8.1.310.0090.00016.78
8.1.300.0060.00317.80
8.1.290.0100.00018.88
8.1.280.0080.00625.92
8.1.270.0040.00420.70
8.1.260.0040.00426.35
8.1.250.0100.00028.09
8.1.240.0060.00322.59
8.1.230.0050.00520.76
8.1.220.0040.00417.77
8.1.210.0050.00318.78
8.1.200.0030.00717.35
8.1.190.0030.00517.36
8.1.180.0000.00818.77
8.1.170.0000.00818.66
8.1.160.0070.00019.02
8.1.150.0040.00418.98
8.1.140.0090.00319.77
8.1.130.0100.00318.72
8.1.120.0110.00217.43
8.1.110.0100.00317.46
8.1.100.0100.00317.51
8.1.90.0060.00717.42
8.1.80.0060.00617.54
8.1.70.0070.00517.48
8.1.60.0100.00317.60
8.1.50.0100.00317.55
8.1.40.0070.00817.68
8.1.30.0120.00317.59
8.1.20.0100.00417.64
8.1.10.0100.00517.51
8.1.00.0130.00217.59
8.0.300.0050.00219.65
8.0.290.0070.00016.75
8.0.280.0080.00018.42
8.0.270.0060.00916.91
8.0.260.0080.00418.50
8.0.250.0050.00717.01
8.0.240.0020.00816.97
8.0.230.0080.00516.99
8.0.220.0070.00416.87
8.0.210.0070.00516.94
8.0.200.0090.00217.02
8.0.190.0090.00316.96
8.0.180.0080.00416.97
8.0.170.0070.00416.98
8.0.160.0080.00316.92
8.0.150.0070.00216.92
8.0.140.0050.00516.86
8.0.130.0070.00315.17
8.0.120.0020.00716.92
8.0.110.0020.00716.67
8.0.100.0080.00216.91
8.0.90.0060.00416.93
8.0.80.0090.00216.93
8.0.70.0010.00616.93
8.0.60.0060.00116.77
8.0.50.0040.00416.94
8.0.30.0070.00516.92
8.0.20.0050.01017.17
8.0.10.0040.00417.05
8.0.00.0090.00916.96
7.4.330.0030.00615.92
7.4.320.0070.00616.56
7.4.300.0110.00016.55
7.4.290.0120.00116.57
7.4.280.0040.00816.51
7.4.270.0060.00616.55
7.4.260.0100.00214.84
7.4.250.0080.00616.49
7.4.240.0080.00216.54
7.4.230.0100.00216.56
7.4.220.0060.00316.47
7.4.210.0120.00316.43
7.4.200.0020.00916.47
7.4.190.0160.00016.56
7.4.180.0000.01616.47
7.4.160.0080.00716.57
7.4.150.0150.00216.39
7.4.140.0130.00216.41
7.4.130.0050.01216.47
7.4.120.0100.00616.51
7.4.110.0030.01416.51
7.4.100.0100.00816.49
7.4.90.0130.00616.43
7.4.80.0070.00917.88
7.4.70.0130.00516.48
7.4.60.0050.01016.41
7.4.50.0050.00816.48
7.4.40.0130.00716.39
7.4.30.0130.00316.45
7.4.20.0070.00716.50
7.4.10.0130.00016.31
7.4.00.0050.01015.59
7.3.330.0070.00316.30
7.3.320.0060.00514.85
7.3.310.0090.00216.41
7.3.300.0060.00616.36
7.3.290.0080.01016.27
7.3.280.0150.00016.30
7.3.270.0070.00716.34
7.3.260.0140.00216.34
7.3.250.0060.00916.30
7.3.240.0090.00716.39
7.3.230.0110.00516.28
7.3.220.0130.00316.30
7.3.210.0100.00916.33
7.3.200.0110.00716.33
7.3.190.0130.00516.27
7.3.180.0110.00516.41
7.3.170.0080.00816.32
7.3.160.0090.00816.37
7.3.150.0080.00616.30
7.3.140.0090.00516.33
7.3.130.0060.01216.30
7.3.120.0110.00315.38
7.3.110.0070.00915.44
7.3.100.0090.00615.62
7.3.90.0120.00415.52
7.3.80.0080.00615.71
7.3.70.0030.01215.48
7.3.60.0130.00215.60
7.3.50.0130.00515.49
7.3.40.0090.00515.58
7.3.30.0060.01015.39
7.3.20.0090.00715.67
7.3.10.0100.00715.53
7.3.00.0110.00415.56
7.2.340.0150.00016.33
7.2.330.0110.00516.50
7.2.320.0100.00916.54
7.2.310.0110.00816.52
7.2.300.0110.00516.39
7.2.290.0100.00516.62
7.2.280.0050.00916.30
7.2.270.0050.01016.52
7.2.260.0110.00416.38
7.2.250.0080.01015.55
7.2.240.0140.00215.78
7.2.230.0110.00415.57
7.2.220.0070.00715.68
7.2.210.0080.00815.67
7.2.200.0110.00515.79
7.2.190.0070.01015.91
7.2.180.0110.00615.72
7.2.170.0090.00515.84
7.2.160.0110.00316.47
7.2.150.0130.00716.60
7.2.140.0110.00516.47
7.2.130.0120.00416.79
7.2.120.0070.00716.58
7.2.110.0120.00616.59
7.2.100.0050.01016.72
7.2.90.0080.00816.72
7.2.80.0080.00816.72
7.2.70.0090.00616.72
7.2.60.0160.00016.52
7.2.50.0120.00416.72
7.2.40.0160.00016.72
7.2.30.0140.00316.66
7.2.20.0270.00816.79
7.2.10.0100.00616.79
7.2.00.0120.00316.79

preferences:
60.27 ms | 403 KiB | 5 Q