3v4l.org

run code in 300+ PHP versions simultaneously
<?php function make_recursive($arr, $root = 0, $pid = 'pid', $id = 'id', $child = 'child') { $m = array(); foreach ($arr as $e) { if (!isset($m[$e[$pid]])) $m[$e[$pid]] = array(); if (!isset($m[$e[$id]])) $m[$e[$id]] = array(); $m[$e[$pid]][] = array_merge($e, array($child => &$m[$e[$id]])); } return $m[$root][0]; } $arr = array( array('id' => 5273, 'pid' => 0, 'name' => 'John Doe'), array('id' => 6032, 'pid' => 5273, 'name' => 'Sally Smith'), array('id' => 6034, 'pid' => 6032, 'name' => 'Mike Jones'), array('id' => 6035, 'pid' => 6034, 'name' => 'Jason Williams'), array('id' => 6036, 'pid' => 5273, 'name' => 'Sara Johnson'), array('id' => 6037, 'pid' => 5273, 'name' => 'Dave Wilson'), array('id' => 6038, 'pid' => 6037, 'name' => 'Amy Martin'), ); $re=make_recursive($arr); var_export($re);

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.0060.00916.50
8.3.50.0110.00722.82
8.3.40.0110.01118.97
8.3.30.0090.00618.80
8.3.20.0040.00421.49
8.3.10.0030.00522.14
8.3.00.0060.00319.91
8.2.180.0100.01018.08
8.2.170.0000.01522.96
8.2.160.0070.00720.25
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0080.00019.66
8.2.110.0090.00020.99
8.2.100.0100.00319.25
8.2.90.0000.00818.03
8.2.80.0040.00419.23
8.2.70.0080.00017.63
8.2.60.0040.00417.93
8.2.50.0030.00518.10
8.2.40.0040.00420.21
8.2.30.0020.00519.36
8.2.20.0050.00218.15
8.2.10.0000.00818.15
8.2.00.0070.00017.74
8.1.280.0110.01125.92
8.1.270.0030.00522.15
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00022.18
8.1.230.0040.00720.95
8.1.220.0040.00417.76
8.1.210.0030.00618.96
8.1.200.0100.00017.48
8.1.190.0030.00617.23
8.1.180.0040.00418.10
8.1.170.0000.00818.66
8.1.160.0000.00818.92
8.1.150.0000.00722.11
8.1.140.0040.00419.56
8.1.130.0040.00419.04
8.1.120.0030.00317.50
8.1.110.0080.00017.48
8.1.100.0050.00317.49
8.1.90.0000.00817.43
8.1.80.0050.00317.46
8.1.70.0000.00717.47
8.1.60.0060.00317.68
8.1.50.0000.00817.57
8.1.40.0030.00617.50
8.1.30.0080.00017.57
8.1.20.0040.00417.68
8.1.10.0000.00717.43
8.1.00.0030.00517.33
8.0.300.0040.00420.21
8.0.290.0060.00316.75
8.0.280.0070.00018.48
8.0.270.0040.00417.29
8.0.260.0030.00317.40
8.0.250.0070.00017.03
8.0.240.0040.00416.85
8.0.230.0000.00717.03
8.0.220.0070.00016.93
8.0.210.0070.00016.79
8.0.200.0080.00016.95
8.0.190.0040.00416.88
8.0.180.0000.00716.94
8.0.170.0030.00516.97
8.0.160.0080.00016.91
8.0.150.0090.00316.82
8.0.140.0040.00316.79
8.0.130.0060.00013.32
8.0.120.0040.00416.93
8.0.110.0050.00316.96
8.0.100.0000.00716.82
8.0.90.0040.00416.97
8.0.80.0110.00416.98
8.0.70.0050.00216.81
8.0.60.0040.00416.88
8.0.50.0000.00716.79
8.0.30.0060.00917.03
8.0.20.0100.00817.40
8.0.10.0000.00817.08
8.0.00.0090.00916.67
7.4.330.0030.00315.55
7.4.320.0030.00316.53
7.4.300.0000.00716.66
7.4.290.0020.00516.55
7.4.280.0050.00216.43
7.4.270.0000.00616.45
7.4.260.0030.00616.54
7.4.250.0050.00316.45
7.4.240.0000.00716.50
7.4.230.0030.00316.52
7.4.220.0060.01216.70
7.4.210.0090.00616.61
7.4.200.0040.00416.66
7.4.150.0060.01217.40
7.4.140.0090.00817.86
7.4.130.0110.00616.52
7.4.120.0100.00916.53
7.4.110.0080.00816.52
7.4.100.0170.00416.43
7.4.90.0070.01116.39
7.4.80.0060.01019.39
7.4.70.0030.01216.66
7.4.60.0100.00616.56
7.4.50.0060.01016.33
7.4.40.0060.01516.40
7.4.30.0100.00716.50
7.4.00.0100.00715.15
7.3.330.0000.00713.36
7.3.320.0050.00013.32
7.3.310.0070.00016.42
7.3.300.0000.00716.26
7.3.290.0070.00016.27
7.3.280.0080.01116.40
7.3.270.0100.00717.40
7.3.260.0050.01116.54
7.3.250.0090.00816.42
7.3.240.0120.00516.54
7.3.230.0130.00316.61
7.3.210.0080.00816.69
7.3.200.0120.00616.38
7.3.190.0150.00016.69
7.3.180.0060.01016.40
7.3.170.0120.00316.36
7.3.160.0100.00616.45
7.3.120.0090.00615.01
7.3.110.0090.00614.98
7.3.100.0070.00314.81
7.3.90.0120.00314.78
7.3.80.0100.00314.70
7.3.70.0030.01314.78
7.3.60.0000.01514.90
7.3.50.0070.00714.96
7.3.40.0090.00614.85
7.3.30.0030.01014.60
7.3.20.0060.00316.79
7.3.10.0030.01216.78
7.3.00.0070.00716.59
7.2.330.0180.00016.70
7.2.320.0030.01316.80
7.2.310.0120.00416.82
7.2.300.0100.01416.80
7.2.290.0110.00716.73
7.2.240.0090.00615.33
7.2.230.0030.01515.18
7.2.220.0040.00815.29
7.2.210.0030.01514.97
7.2.200.0060.00614.85
7.2.190.0060.00914.84
7.2.180.0100.00615.07
7.2.170.0060.01315.09
7.2.160.0030.01014.79
7.2.150.0070.01016.77
7.2.140.0070.01016.71
7.2.130.0100.00717.04
7.2.120.0130.00317.14
7.2.110.0080.00416.88
7.2.100.0110.00716.93
7.2.90.0070.01116.96
7.2.80.0030.01217.05
7.2.70.0000.01417.09
7.2.60.0030.01516.90
7.2.50.0000.01916.92
7.2.40.0040.01116.92
7.2.30.0030.01317.07
7.2.20.0110.00716.82
7.2.10.0070.01117.00
7.2.00.0030.01316.66
7.1.330.0060.00615.63
7.1.320.0000.01715.61
7.1.310.0060.00915.97
7.1.300.0040.01115.76
7.1.290.0060.01216.00
7.1.280.0030.01215.89
7.1.270.0070.01015.74
7.1.260.0120.00016.06
7.1.250.0060.00615.91
7.1.200.0030.00915.76
7.1.110.0070.01018.08
7.1.100.0080.00518.15
7.1.90.0090.00918.20
7.1.80.0000.01417.90
7.1.70.0100.00617.10
7.1.60.0090.01225.96
7.1.50.0190.00934.65
7.1.40.0220.00634.28
7.1.30.0120.01534.43
7.1.20.0160.01634.28
7.1.10.0200.03818.47
7.1.00.0280.04118.57
7.0.250.0110.00317.52
7.0.240.0070.00717.61
7.0.230.0040.01117.80
7.0.220.0070.00717.75
7.0.210.0090.00616.72
7.0.200.0060.00816.69
7.0.190.0060.00916.46
7.0.180.0030.01216.27
7.0.170.0030.01216.20
7.0.160.0060.01216.29
7.0.150.0580.03118.11
7.0.140.0250.03718.17
7.0.130.0220.03218.28
7.0.120.0180.03518.28
7.0.110.0220.03218.22
7.0.100.0200.03318.08
7.0.90.0190.03618.29
7.0.80.0180.03418.13
7.0.70.0210.03218.10
7.0.60.0180.03718.10
7.0.50.0180.03318.12
7.0.40.0200.03318.19
7.0.30.0180.03118.29
7.0.20.0180.03318.22
7.0.10.0200.03018.15
7.0.00.0220.03118.16

preferences:
57.43 ms | 401 KiB | 5 Q