3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('Content-Type: application/json; charset="utf-8"'); /** * Helper function * * @param array $d flat data, implementing a id/parent id (adjacency list) structure * @param mixed $r root id, node to return * @param string $pk parent id index * @param string $k id index * @param string $c children index * @return array */ function makeRecursive($d, $r = 0, $pk = 'parent', $k = 'id', $c = 'children') { $m = array(); foreach ($d as $e) { isset($m[$e[$pk]]) ?: $m[$e[$pk]] = array(); isset($m[$e[$k]]) ?: $m[$e[$k]] = array(); $m[$e[$pk]][] = array_merge($e, array($c => &$m[$e[$k]])); } return $m[$r][0]; // remove [0] if there could be more than one root nodes } echo json_encode(makeRecursive(array( array('id' => 5273, 'parent' => 0, 'name' => 'John Doe'), array('id' => 6032, 'parent' => 5273, 'name' => 'Sally Smith'), array('id' => 6034, 'parent' => 6032, 'name' => 'Mike Jones'), array('id' => 6035, 'parent' => 6034, 'name' => 'Jason Williams'), array('id' => 6036, 'parent' => 5273, 'name' => 'Sara Johnson'), array('id' => 6037, 'parent' => 5273, 'name' => 'Dave Wilson'), array('id' => 6038, 'parent' => 6037, 'name' => 'Amy Martin'), )));

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.10.0160.00320.54
8.3.140.0120.00616.60
8.3.130.0090.00616.77
8.3.120.0000.01020.90
8.3.110.0070.00316.50
8.3.100.0030.00716.65
8.3.90.0030.01326.77
8.3.80.0060.00317.97
8.3.70.0080.00816.50
8.3.60.0140.00318.56
8.3.50.0130.00521.25
8.3.40.0070.00718.68
8.3.30.0070.00718.72
8.3.20.0080.00018.90
8.3.10.0000.00721.85
8.3.00.0070.00021.86
8.2.260.0070.01118.69
8.2.250.0090.00016.90
8.2.240.0030.00717.31
8.2.230.0090.00020.94
8.2.220.0030.00737.54
8.2.210.0040.00426.77
8.2.200.0060.00316.88
8.2.190.0090.00618.29
8.2.180.0150.00616.50
8.2.170.0150.00022.96
8.2.160.0070.00719.33
8.2.150.0030.00524.18
8.2.140.0070.00024.66
8.2.130.0070.01026.16
8.2.120.0040.00421.19
8.2.110.0050.00521.04
8.2.100.0090.00318.03
8.2.90.0040.00418.28
8.2.80.0080.00017.97
8.2.70.0040.00418.05
8.2.60.0110.00019.34
8.2.50.0040.00819.46
8.2.40.0000.00820.47
8.2.30.0000.00721.21
8.2.20.0040.00418.11
8.2.10.0000.00718.01
8.2.00.0050.00317.69
8.1.310.0060.01318.33
8.1.300.0050.00517.84
8.1.290.0060.00630.84
8.1.280.0070.01025.92
8.1.270.0090.00024.02
8.1.260.0000.00726.35
8.1.250.0030.00628.09
8.1.240.0060.00322.02
8.1.230.0070.00722.08
8.1.220.0000.00817.74
8.1.210.0040.00418.80
8.1.200.0050.00317.36
8.1.190.0090.00017.35
8.1.180.0030.00518.10
8.1.170.0040.00418.65
8.1.160.0050.00222.14
8.1.150.0100.00018.91
8.1.140.0000.00819.59
8.1.130.0030.00317.45
8.1.120.0030.00517.45
8.1.110.0040.00417.34
8.1.100.0080.00017.48
8.1.90.0000.00717.49
8.1.80.0000.00717.38
8.1.70.0040.00417.44
8.1.60.0030.00517.61
8.1.50.0080.00017.55
8.1.40.0080.00017.49
8.1.30.0030.00517.66
8.1.20.0030.00517.64
8.1.10.0030.00617.66
8.1.00.0000.00817.46
8.0.300.0050.00220.03
8.0.290.0000.00816.63
8.0.280.0040.00418.34
8.0.270.0000.00716.85
8.0.260.0030.00316.75
8.0.250.0000.00716.88
8.0.240.0030.00316.84
8.0.230.0040.00416.90
8.0.220.0050.00316.94
8.0.210.0030.00316.80
8.0.200.0060.00016.84
8.0.190.0000.00716.84
8.0.180.0080.00016.89
8.0.170.0050.00316.95
8.0.160.0040.00416.93
8.0.150.0000.00716.95
8.0.140.0000.00716.85
8.0.130.0030.00713.27
8.0.120.0070.00414.53
8.0.110.0070.00414.50
8.0.100.0050.00514.54
8.0.90.0080.00214.46
8.0.80.0070.00714.48
8.0.70.0080.00314.45
8.0.60.0080.00314.49
8.0.50.0100.00114.46
8.0.30.0090.01015.96
8.0.20.0090.00916.28
8.0.10.0110.00715.58
8.0.00.0050.01015.87
7.4.330.0000.00615.55
7.4.320.0050.00216.44
7.4.300.0030.00316.61
7.4.290.0030.00316.43
7.4.280.0030.00616.59
7.4.270.0040.00416.50
7.4.260.0000.00716.52
7.4.250.0050.00313.57
7.4.240.0050.00414.89
7.4.230.0090.00314.42
7.4.220.0120.00514.34
7.4.210.0080.00814.40
7.4.200.0060.00514.27
7.4.190.0100.00113.38
7.4.180.0120.00113.28
7.4.160.0110.00615.30
7.4.150.0140.00415.42
7.4.140.0100.00716.18
7.4.130.0100.00715.70
7.4.120.0090.00815.71
7.4.110.0090.00915.52
7.4.100.0100.00715.70
7.4.90.0110.00615.63
7.4.80.0100.00715.97
7.4.70.0100.00715.83
7.4.60.0100.00815.82
7.4.50.0100.00915.82
7.4.40.0120.00515.67
7.4.30.0080.01015.74
7.4.20.0100.00715.72
7.4.10.0100.00915.75
7.4.00.0090.00815.50
7.3.330.0000.00713.21
7.3.320.0070.00313.26
7.3.310.0090.00114.27
7.3.300.0080.00314.28
7.3.290.0100.00415.04
7.3.280.0110.00515.65
7.3.270.0100.00714.83
7.3.260.0100.00615.55
7.3.250.0110.00815.65
7.3.240.0120.00515.61
7.3.230.0100.00915.56
7.3.220.0110.00715.34
7.3.210.0090.01015.55
7.3.200.0110.00615.61
7.3.190.0110.00715.64
7.3.180.0110.00715.79
7.3.170.0090.00915.72
7.3.160.0110.00815.75
7.3.150.0120.00615.68
7.3.140.0100.00615.65
7.3.130.0120.00715.69
7.3.120.0100.00815.54
7.3.110.0090.00815.46
7.3.100.0080.00915.46
7.3.90.0100.00715.56
7.3.80.0100.00715.47
7.3.70.0110.00615.48
7.3.60.0070.00915.50
7.3.50.0080.00915.52
7.3.40.0110.00715.48
7.3.30.0080.00915.49
7.3.20.0210.00715.83
7.3.10.0150.00915.79
7.3.00.0320.00615.66
7.2.340.0160.00415.44
7.2.330.0150.00715.80
7.2.320.0130.00715.71
7.2.310.0120.00915.85
7.2.300.0120.00915.82
7.2.290.0130.00915.84
7.2.280.0110.00915.82
7.2.270.0140.00515.80
7.2.260.0130.00815.79
7.2.250.0140.00715.82
7.2.240.0120.00715.63
7.2.230.0100.00915.64
7.2.220.0140.00715.64
7.2.210.0100.01015.66
7.2.200.0110.00815.68
7.2.190.0120.00715.64
7.2.180.0130.00715.66
7.2.170.0120.00815.73
7.2.160.0130.00715.72
7.2.150.0180.00816.05
7.2.140.0170.00816.02
7.2.130.0230.00715.89
7.2.120.0220.00715.89
7.2.110.0240.00915.88
7.2.100.0250.00915.85
7.2.90.0280.00615.92
7.2.80.0250.00515.95
7.2.70.0260.00815.97
7.2.60.0240.00815.96
7.2.50.0220.00715.87
7.2.40.0260.01016.01
7.2.30.0270.00816.06
7.2.20.0230.00916.16
7.2.10.0260.00916.21
7.2.00.0250.01016.17
7.1.330.0130.00914.99
7.1.320.0150.00715.00
7.1.310.0160.00714.99
7.1.300.0160.00614.95
7.1.290.0150.00814.97
7.1.280.0140.00814.94
7.1.270.0130.00814.99
7.1.260.0160.00814.99
7.1.250.0210.00714.80
7.1.240.0340.00714.72
7.1.230.0250.00614.76
7.1.220.0230.00814.72
7.1.210.0310.00914.79
7.1.200.0250.00614.84
7.1.190.0250.00714.81
7.1.180.0290.00814.79
7.1.170.0220.00914.75
7.1.160.0280.00614.71
7.1.150.0270.00814.91
7.1.140.0320.00715.01
7.1.130.0310.00815.02
7.1.120.0270.00915.00
7.1.110.0260.00915.04
7.1.100.0310.00715.02
7.1.90.0300.00715.00
7.1.80.0260.00815.10
7.1.70.0240.00914.91
7.1.60.0340.01017.98
7.1.50.0300.00917.93
7.1.40.0230.00917.85
7.1.30.0260.00717.89
7.1.20.0220.00917.84
7.1.10.0220.00714.89
7.1.00.0200.00814.80
7.0.330.0240.00814.51
7.0.320.0230.00714.57
7.0.310.0280.00714.56
7.0.300.0300.00614.52
7.0.290.0270.00614.51
7.0.280.0290.00814.56
7.0.270.0240.00914.78
7.0.260.0270.00814.77
7.0.250.0270.00814.84
7.0.240.0260.00814.82
7.0.230.0300.00814.78
7.0.220.0260.00914.78
7.0.210.0280.00914.59
7.0.200.0290.00714.65
7.0.190.0310.00714.65
7.0.180.0220.00814.59
7.0.170.0230.00714.58
7.0.160.0200.00814.49
7.0.150.0240.00814.61
7.0.140.0350.00914.60
7.0.130.0320.00814.61
7.0.120.0240.00714.63
7.0.110.0200.00914.51
7.0.100.0250.00814.60
7.0.90.0230.00714.52
7.0.80.0240.00914.55
7.0.70.0230.01014.54
7.0.60.0250.00714.51
7.0.50.0210.00814.56
7.0.40.0200.00914.61
7.0.30.0190.00814.61
7.0.20.0220.00714.57
7.0.10.0380.00714.54
7.0.00.0210.00914.51
5.6.400.0140.00815.01
5.6.390.0130.01015.06
5.6.380.0140.00914.97
5.6.370.0130.01114.96
5.6.360.0120.00914.97
5.6.350.0140.00814.94
5.6.340.0150.00814.85
5.6.330.0140.00814.90
5.6.320.0110.01114.93
5.6.310.0140.00914.93
5.6.300.0140.01715.81
5.6.290.0160.01715.86
5.6.280.0140.01915.94
5.6.270.0150.01915.88
5.6.260.0150.02015.89
5.6.250.0130.01915.84
5.6.240.0140.01915.93
5.6.230.0130.01915.88
5.6.220.0150.01715.88
5.6.210.0150.01615.85
5.6.200.0140.01915.88
5.6.190.0160.01815.88
5.6.180.0160.01615.86
5.6.170.0140.02015.93
5.6.160.0160.01915.91
5.6.150.0140.01915.85
5.6.140.0140.02015.89
5.6.130.0150.01715.92
5.6.120.0130.02115.88
5.6.110.0140.01815.90
5.6.100.0150.01815.87
5.6.90.0130.01815.88
5.6.80.0110.02015.73
5.6.70.0140.01815.77
5.6.60.0120.02015.72
5.6.50.0140.01715.74
5.6.40.0150.01915.75
5.6.30.0140.01815.74
5.6.20.0150.01815.66
5.6.10.0170.01615.73
5.6.00.0160.01715.70

preferences:
51.68 ms | 403 KiB | 5 Q