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' => 5273, '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.3.60.0160.00018.30
8.3.50.0100.01018.24
8.3.40.0120.00318.79
8.3.30.0090.00618.85
8.3.20.0040.00421.90
8.3.10.0070.00021.95
8.3.00.0030.00619.63
8.2.180.0150.00416.75
8.2.170.0080.00822.96
8.2.160.0040.01120.43
8.2.150.0000.00825.66
8.2.140.0030.00524.66
8.2.130.0000.00719.45
8.2.120.0080.00026.35
8.2.110.0060.00322.11
8.2.100.0090.00317.91
8.2.90.0090.00017.91
8.2.80.0000.00818.34
8.2.70.0000.00817.80
8.2.60.0000.00817.93
8.2.50.0000.00818.22
8.2.40.0040.00420.37
8.2.30.0000.00719.50
8.2.20.0040.00418.01
8.2.10.0070.00018.24
8.2.00.0030.00318.06
8.1.280.0110.00425.92
8.1.270.0050.00324.00
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00320.43
8.1.230.0070.00720.89
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0090.00017.22
8.1.180.0000.00818.10
8.1.170.0040.00418.89
8.1.160.0030.00518.86
8.1.150.0050.00219.03
8.1.140.0000.00717.78
8.1.130.0060.00318.91
8.1.120.0000.00817.33
8.1.110.0000.00717.36
8.1.100.0020.00517.45
8.1.90.0040.00417.44
8.1.80.0070.00017.38
8.1.70.0000.00817.40
8.1.60.0000.00917.50
8.1.50.0030.00617.56
8.1.40.0000.00717.45
8.1.30.0080.00017.56
8.1.20.0030.00617.72
8.1.10.0060.00317.54
8.1.00.0050.00317.52
8.0.300.0080.00020.03
8.0.290.0040.00416.75
8.0.280.0070.00018.47
8.0.270.0000.00717.18
8.0.260.0000.00617.19
8.0.250.0030.00316.82
8.0.240.0090.00016.85
8.0.230.0000.00716.98
8.0.220.0030.00516.93
8.0.210.0000.00716.80
8.0.200.0000.00716.83
8.0.190.0000.00716.97
8.0.180.0020.00516.89
8.0.170.0070.00316.93
8.0.160.0000.00817.00
8.0.150.0000.00716.93
8.0.140.0040.00416.87
8.0.130.0030.00313.41
8.0.120.0040.00416.79
8.0.110.0050.00316.84
8.0.100.0000.00716.75
8.0.90.0000.00817.00
8.0.80.0060.00916.91
8.0.70.0040.00416.90
8.0.60.0000.00816.79
8.0.50.0030.00516.77
8.0.30.0080.01117.01
8.0.20.0120.00617.40
8.0.10.0070.00017.02
8.0.00.0080.00916.85
7.4.330.0000.00515.55
7.4.320.0030.00316.47
7.4.300.0030.00316.66
7.4.290.0030.00316.63
7.4.280.0000.00816.51
7.4.270.0000.00716.42
7.4.260.0030.00616.50
7.4.250.0070.00016.53
7.4.240.0050.00316.49
7.4.230.0000.00716.33
7.4.220.0040.00416.42
7.4.210.0060.00816.62
7.4.200.0030.00516.59
7.4.160.0080.01016.51
7.4.140.0130.00617.86
7.4.130.0140.00316.63
7.4.120.0100.00816.54
7.4.110.0070.01016.43
7.4.100.0100.01016.46
7.4.90.0120.00616.47
7.4.80.0150.01219.39
7.4.70.0150.00516.40
7.4.60.0130.00316.26
7.4.50.0030.01216.52
7.4.40.0130.00716.38
7.4.00.0070.00714.69
7.3.330.0000.00513.24
7.3.320.0000.00513.45
7.3.310.0030.00516.27
7.3.300.0000.00716.25
7.3.290.0000.00716.34
7.3.280.0080.00816.39
7.3.260.0110.00816.45
7.3.240.0110.00716.36
7.3.230.0030.01316.29
7.3.210.0090.00616.57
7.3.200.0090.01316.49
7.3.190.0080.00816.38
7.3.180.0040.01216.58
7.3.170.0130.00316.32
7.3.160.0150.00016.51
7.3.120.0030.01115.19
7.3.110.0030.00914.98
7.3.100.0030.01315.13
7.3.90.0000.01314.58
7.3.80.0110.00415.05
7.3.70.0060.00814.80
7.3.60.0070.01014.96
7.3.50.0070.01014.93
7.3.40.0060.00914.69
7.3.30.0030.01014.66
7.3.20.0030.01016.77
7.3.10.0030.00816.68
7.3.00.0030.00816.72
7.2.330.0080.01616.47
7.2.320.0110.00616.69
7.2.310.0130.00516.87
7.2.300.0080.01116.71
7.2.290.0080.01616.82
7.2.240.0120.00015.00
7.2.230.0000.01614.93
7.2.220.0110.00015.04
7.2.210.0060.00614.71
7.2.200.0040.01115.21
7.2.190.0070.00715.25
7.2.180.0060.00915.09
7.2.170.0080.00815.23
7.2.160.0030.00915.08
7.2.150.0090.00616.86
7.2.140.0040.01116.75
7.2.130.0080.00816.76
7.2.120.0070.00716.94
7.2.110.0070.00816.79
7.2.100.0050.00816.92
7.2.90.0040.01216.96
7.2.80.0060.00816.88
7.2.70.0060.00616.80
7.2.60.0080.00416.93
7.2.50.0100.00416.81
7.2.40.0150.00917.10
7.2.30.0190.00917.34
7.2.20.0180.01117.39
7.2.10.0210.00617.32
7.2.00.0170.01117.16
7.1.330.0040.00715.45
7.1.320.0000.01415.89
7.1.310.0070.00315.89
7.1.300.0060.00615.90
7.1.290.0060.00615.57
7.1.280.0060.00915.77
7.1.270.0000.01216.00
7.1.260.0060.00915.80
7.1.250.0050.00815.87
7.1.200.0030.01015.72
7.1.160.0350.00816.81
7.1.150.0530.01416.79
7.1.140.0340.01017.00
7.1.130.0370.01516.70
7.1.120.0480.01116.78
7.1.110.0370.00716.18
7.1.100.0380.00716.37
7.1.90.0290.00716.38
7.1.80.0300.00816.13
7.1.70.0350.01015.46
7.1.60.0490.00933.20
7.1.50.0480.00932.91
7.1.40.0600.01432.55
7.1.30.0710.01532.93
7.1.20.0550.01732.67
7.1.10.1500.01414.82
7.1.00.0360.01114.90
7.0.290.1240.01516.48
7.0.270.0430.01116.77
7.0.260.0360.01516.68
7.0.250.0430.01115.86
7.0.240.0400.00815.96
7.0.230.0320.01215.98
7.0.220.0360.00715.89
7.0.210.0380.00614.75
7.0.200.0320.01014.84
7.0.190.0330.00814.88
7.0.180.0510.01214.47
7.0.170.0470.00714.52
7.0.160.0470.00814.73
7.0.150.0420.01314.57
7.0.140.0640.01214.50
7.0.130.0370.01014.83
7.0.120.0350.00914.87
7.0.110.0440.01314.54
7.0.100.0510.00714.70
7.0.90.0460.01114.72
7.0.80.0510.00714.79
7.0.70.0520.00714.49
7.0.60.0340.00614.41
7.0.50.0620.01414.76
7.0.40.0380.00814.88
7.0.30.0380.00814.93
7.0.20.0630.01514.59
7.0.10.0590.01114.78
7.0.00.0530.01314.56
5.6.300.0250.07920.68
5.6.290.0220.05220.61
5.6.280.0160.06320.95
5.6.270.0210.05320.94
5.6.260.0190.05520.78
5.6.250.0160.05820.87
5.6.240.0160.05920.72
5.6.230.0150.06020.75
5.6.220.0200.07720.72
5.6.210.0200.05220.59
5.6.200.0150.05920.96
5.6.190.0200.05420.92
5.6.180.0180.05520.73
5.6.170.0180.05820.92
5.6.160.0130.06120.77
5.6.150.0150.05920.91
5.6.140.0220.06320.99
5.6.130.0210.07020.89
5.6.120.0180.05920.73
5.6.110.0190.05520.79
5.6.100.0170.07420.71
5.6.90.0140.06220.82
5.6.80.0150.05320.08
5.6.70.0140.05620.29
5.6.60.0160.05820.26
5.6.50.0220.05520.11
5.6.40.0200.07420.20
5.6.30.0150.06020.06
5.6.20.0120.06120.11
5.6.10.0140.05720.25
5.6.00.0180.05620.26
5.5.380.0170.05217.42
5.5.370.0150.07817.52
5.5.360.0140.05717.62
5.5.350.0120.06917.48
5.5.340.0110.06318.04
5.5.330.0130.05618.04
5.5.320.0120.05718.03
5.5.310.0230.07218.11
5.5.300.0200.05318.04
5.5.290.0180.05417.74
5.5.280.0210.05918.02
5.5.270.0120.05917.93
5.5.260.0100.06218.01
5.5.250.0130.05717.59
5.5.240.0230.04917.35
5.5.230.0120.05817.41
5.5.220.0160.05117.14
5.5.210.0110.05617.15
5.5.200.0190.06717.39
5.5.190.0120.05617.41
5.5.180.0140.05617.41
5.5.160.0160.05417.29
5.5.150.0140.05317.35
5.5.140.0230.06517.14
5.5.130.0150.05417.40
5.5.120.0180.05517.14
5.5.110.0180.06417.38
5.5.100.0160.05617.00
5.5.90.0110.05617.28
5.5.80.0150.05217.19
5.5.70.0160.05217.27
5.5.60.0270.05217.28
5.5.50.0140.07417.27
5.5.40.0130.05717.27
5.5.30.0120.06017.27
5.5.20.0240.06917.24
5.5.10.0160.05917.01
5.5.00.0170.07017.26
5.4.450.0180.05619.37
5.4.440.0150.05719.31
5.4.430.0200.05419.34
5.4.420.0140.06919.25
5.4.410.0180.04919.18
5.4.400.0180.05118.87
5.4.390.0120.05819.00
5.4.380.0180.05719.00
5.4.370.0210.07119.15
5.4.360.0180.07119.01
5.4.350.0110.05919.11
5.4.340.0150.05519.08
5.4.320.0230.06018.84
5.4.310.0140.05319.25
5.4.300.0150.07219.15
5.4.290.0170.06818.87
5.4.280.0220.07419.01
5.4.270.0170.05919.04
5.4.260.0190.06419.15
5.4.250.0130.06619.10
5.4.240.0120.06519.23
5.4.230.0160.05218.98
5.4.220.0210.06318.92
5.4.210.0240.06419.14
5.4.200.0270.05819.00
5.4.190.0160.08019.07
5.4.180.0150.05419.09
5.4.170.0100.06618.91
5.4.160.0190.05019.10
5.4.150.0130.06419.22
5.4.140.0120.05716.72
5.4.130.0140.05316.65
5.4.120.0110.06416.39
5.4.110.0170.06916.69
5.4.100.0180.04716.64
5.4.90.0160.06116.42
5.4.80.0110.05316.56
5.4.70.0170.04816.71
5.4.60.0180.05016.56
5.4.50.0190.05616.62
5.4.40.0180.04616.71
5.4.30.0150.05616.54
5.4.20.0250.04216.60
5.4.10.0150.06116.66
5.4.00.0210.06116.15
5.3.290.0190.06814.96
5.3.280.0140.05714.65
5.3.270.0100.05514.89
5.3.260.0120.05514.68
5.3.250.0090.06814.89
5.3.240.0130.06414.79
5.3.230.0180.06214.67
5.3.220.0210.06114.85
5.3.210.0210.06014.76
5.3.200.0120.07914.87
5.3.190.0210.06414.84
5.3.180.0150.05114.64
5.3.170.0110.05514.62
5.3.160.0130.05714.86
5.3.150.0190.06014.66
5.3.140.0120.05414.84
5.3.130.0160.07214.56
5.3.120.0130.05514.85
5.3.110.0220.06714.82
5.3.100.0160.04814.24
5.3.90.0130.05014.21
5.3.80.0180.05114.22
5.3.70.0160.04914.31
5.3.60.0140.04914.03
5.3.50.0170.04914.08
5.3.40.0150.04614.08
5.3.30.0170.05313.77
5.3.20.0120.05113.85
5.3.10.0110.05113.97
5.3.00.0170.05913.86
5.2.170.0180.03511.28
5.2.160.0100.04011.43
5.2.150.0080.05711.37
5.2.140.0080.04511.27
5.2.130.0110.05011.32
5.2.120.0120.05110.98
5.2.110.0120.04611.10
5.2.100.0120.05811.17
5.2.90.0090.04711.41
5.2.80.0150.03611.39
5.2.70.0120.04211.30
5.2.60.0110.05811.05
5.2.50.0080.04711.02
5.2.40.0090.04011.21
5.2.30.0080.04311.09
5.2.20.0110.04811.21
5.2.10.0180.04811.07
5.2.00.0110.05511.02
5.1.60.0150.0439.99
5.1.50.0090.03910.32
5.1.40.0130.03810.03
5.1.30.0120.03410.62
5.1.20.0080.04510.36
5.1.10.0130.03710.39
5.1.00.0070.04610.39
5.0.50.0130.0348.75
5.0.40.0080.0298.48
5.0.30.0080.0518.52
5.0.20.0050.0408.48
5.0.10.0050.0328.48
5.0.00.0080.0448.48
4.4.90.0060.0218.48
4.4.80.0060.0228.48
4.4.70.0050.0238.48
4.4.60.0080.0218.48
4.4.50.0050.0268.48
4.4.40.0090.0438.48
4.4.30.0050.0248.48
4.4.20.0070.0278.48
4.4.10.0060.0228.48
4.4.00.0110.0408.48
4.3.110.0030.0248.48
4.3.100.0060.0278.48
4.3.90.0100.0248.48
4.3.80.0080.0348.48
4.3.70.0070.0268.48
4.3.60.0050.0248.48
4.3.50.0060.0248.48
4.3.40.0050.0338.48
4.3.30.0080.0208.48
4.3.20.0060.0268.48
4.3.10.0060.0238.48
4.3.00.0050.0268.48

preferences:
75.09 ms | 401 KiB | 5 Q