3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['id' => 1, 'user' => ['rating' => ['top' => 50, 'avg' => 30]]], ['id' => 2, 'user' => ['rating' => ['top' => 60, 'avg' => 10]]], ['id' => 3, 'user' => ['rating' => ['top' => 25, 'avg' => 12]]], ['id' => 4, 'user' => ['rating' => ['top' => 30, 'avg' => 20]]], ['id' => 5, 'user' => ['rating' => ['top' => 30, 'avg' => 5]]], ]; shuffle($data); function sortBy(&$array, $field) { $accessor = function($row, $path) { $steps = explode('.', $path); $return = $row[array_shift($steps)]; while ($level = array_shift($steps)) { $return =& $return[$level]; } return $return; }; usort($array, function ($a, $b) use ($field, $accessor) { $aVal = $accessor($a, $field); $bVal = $accessor($b, $field); return $aVal <=> $bVal; }); } sortBy($data, 'id'); print_r($data); sortBy($data, 'user.rating.top'); print_r($data); sortBy($data, 'user.rating.avg'); print_r($data);

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)
7.4.10.0060.01314.88
7.4.00.0030.01315.14
7.3.130.0090.00614.66
7.3.120.0030.01414.69
7.3.110.0040.01214.80
7.3.100.0080.00515.03
7.3.90.0030.01314.69
7.3.80.0070.00414.75
7.3.70.0080.00815.02
7.3.60.0120.00614.97
7.3.50.0030.00914.54
7.3.40.0040.00414.86
7.3.30.0070.01014.46
7.3.20.0060.00616.69
7.3.10.0060.00616.43
7.3.00.0040.00916.49
7.2.260.0060.01215.13
7.2.250.0090.00915.09
7.2.240.0030.01014.89
7.2.230.0070.00715.11
7.2.220.0110.00415.00
7.2.210.0060.00915.30
7.2.200.0110.00415.22
7.2.190.0000.01215.02
7.2.180.0060.01014.89
7.2.170.0070.00315.11
7.2.160.0000.01214.91
7.2.150.0120.00316.68
7.2.140.0040.01216.96
7.2.130.0050.00816.87
7.2.120.0080.00716.85
7.2.110.0090.00216.98
7.2.100.0350.00516.22
7.2.90.0310.01016.34
7.2.80.0340.00916.26
7.2.70.0280.01016.33
7.2.60.0280.00916.20
7.2.50.0340.00516.26
7.2.40.0390.01116.24
7.2.30.0350.00616.30
7.2.20.0260.00816.32
7.2.10.0260.00716.18
7.2.00.0320.01216.27
7.1.330.0070.00715.68
7.1.320.0000.00915.61
7.1.310.0030.01615.88
7.1.300.0060.00615.69
7.1.290.0060.00915.66
7.1.280.0100.00315.88
7.1.270.0030.01015.77
7.1.260.0100.00315.57
7.1.250.0090.00715.62
7.1.240.0130.00015.69
7.1.230.0110.00315.77
7.1.220.0360.00814.88
7.1.210.0640.00714.98
7.1.200.0510.00914.83
7.1.190.0420.00714.89
7.1.180.0430.00214.69
7.1.170.0480.00814.60
7.1.160.0450.00614.82
7.1.150.0450.00514.88
7.1.140.0450.00714.81
7.1.130.0410.00914.74
7.1.120.0420.00914.80
7.1.110.0410.00614.74
7.1.100.0560.00514.60
7.1.90.0510.00614.95
7.1.80.0430.00914.86
7.1.70.0560.01015.00
7.1.60.0500.00923.83
7.1.50.0200.01223.75
7.1.40.0420.00923.68
7.1.30.0500.00823.72
7.1.20.0180.00723.72
7.1.10.0100.00414.90
7.1.00.0570.00714.80
7.0.330.0070.01115.52
7.0.320.0070.01115.13
7.0.310.0100.01015.35
7.0.300.0000.01215.51
7.0.290.0100.01015.04
7.0.280.0140.00315.09
7.0.270.0090.00915.17
7.0.260.0100.01015.48
7.0.250.0090.00915.43
7.0.240.0070.00715.26
7.0.230.0060.01315.47
7.0.220.0100.01015.61
7.0.210.0100.00315.65
7.0.200.0090.00915.46
7.0.190.0100.01015.43
7.0.180.0000.01915.51
7.0.170.0100.01015.34
7.0.160.0120.00015.46
7.0.150.0100.00715.25
7.0.140.0200.00015.22
7.0.130.0090.01215.57
7.0.120.0170.00015.61
7.0.110.0070.01015.45
7.0.100.0110.00415.45
7.0.90.0120.00015.48
7.0.80.0160.00015.50
7.0.70.0160.00315.26
7.0.60.0030.01515.14
7.0.50.0070.01315.48
7.0.40.0110.00713.41
7.0.30.0100.01013.54
7.0.20.0090.00313.42
7.0.10.0030.01013.51
7.0.00.0060.01213.34
5.6.400.0000.00914.36
5.6.390.0070.01013.96
5.6.380.0000.01414.03
5.6.370.0000.01314.40
5.6.360.0070.00713.84
5.6.350.0000.01714.39
5.6.340.0100.00313.80
5.6.330.0060.00314.34
5.6.320.0060.00914.24
5.6.310.0000.01314.31
5.6.300.0040.01113.91
5.6.290.0000.01714.34
5.6.280.0130.00014.07
5.6.270.0080.00013.88
5.6.260.0000.01014.08
5.6.250.0130.00314.10
5.6.240.0090.00914.34
5.6.230.0050.00314.04
5.6.220.0030.01013.85
5.6.210.0000.00814.30
5.6.200.0040.00414.12
5.6.190.0040.01014.18
5.6.180.0080.00414.11
5.6.170.0080.00414.14
5.6.160.0030.01014.01
5.6.150.0060.00913.95
5.6.140.0030.01614.10
5.6.130.0000.01614.14
5.6.120.0030.00714.26
5.6.110.0060.00313.89
5.6.100.0030.01214.16
5.6.90.0000.00914.02
5.6.80.0060.00913.82
5.6.70.0080.00314.00
5.6.60.0040.01113.78
5.6.50.0000.01514.14
5.6.40.0060.00613.90
5.6.30.0120.00314.10
5.6.20.0090.00614.11
5.6.10.0080.00813.93
5.6.00.0030.01013.96

preferences:
37.66 ms | 400 KiB | 5 Q