3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pages = array(); $pages[1] = array('id' => 1, 'parent' => 0, 'name' => 'Hello World'); $pages[2] = array('id' => 1, 'parent' => 1, 'name' => 'Child of Hello World'); $pages[3] = array('id' => 1, 'parent' => 0, 'name' => 'Brother of Hello World'); $pages[4] = array('id' => 4, 'parent' => 2, 'name' => 'Grand-child of Hello World'); $pages[6] = array('id' => 6, 'parent' => 4, 'name' => 'Great-grand-child of Hello World'); $children = array(); foreach($pages as $key => $page){ $parent = (int)$page['parent']; if(!isset($children[$parent])){ $children[$parent] = array(); $children[$parent][$key] = array('id' => $page['id'], 'name' => $page['name']); } } $new_pages = recursive_append_children($children[0], $children); function recursive_append_children($arr, $children){ foreach($arr as $key => $page) if(isset($children[$key])) $arr[$key]['children'] = recursive_append_children($children[$key], $children); return $arr; } print_r($new_pages);

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.0200.00416.50
8.3.50.0030.01418.29
8.3.40.0060.00918.77
8.3.30.0110.00418.88
8.3.20.0070.00021.76
8.3.10.0000.00823.52
8.3.00.0040.00422.51
8.2.180.0130.00918.29
8.2.170.0130.00322.96
8.2.160.0140.00019.41
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0080.00026.16
8.2.110.0060.00319.27
8.2.100.0070.00417.84
8.2.90.0070.00317.75
8.2.80.0000.00819.48
8.2.70.0040.00417.93
8.2.60.0000.00818.16
8.2.50.0040.00418.10
8.2.40.0070.00019.43
8.2.30.0070.00019.32
8.2.20.0000.00718.21
8.2.10.0000.00719.34
8.2.00.0000.00719.36
8.1.280.0100.01025.92
8.1.270.0000.00820.64
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0110.00022.09
8.1.230.0070.00320.98
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0060.00317.23
8.1.180.0000.00818.10
8.1.170.0080.00018.47
8.1.160.0080.00018.77
8.1.150.0070.00018.88
8.1.140.0070.00020.91
8.1.130.0070.00020.21
8.1.120.0000.00817.52
8.1.110.0000.00717.52
8.1.100.0050.00217.51
8.1.90.0000.00717.48
8.1.80.0040.00417.48
8.1.70.0050.00217.50
8.1.60.0040.00417.62
8.1.50.0030.00617.49
8.1.40.0040.00417.56
8.1.30.0000.00817.69
8.1.20.0050.00317.58
8.1.10.0030.00617.53
8.1.00.0000.00717.49
8.0.300.0040.00419.90
8.0.290.0040.00416.58
8.0.280.0050.00218.39
8.0.270.0030.00317.20
8.0.260.0030.00320.15
8.0.250.0040.00417.02
8.0.240.0000.00716.90
8.0.230.0070.00016.96
8.0.220.0000.00716.86
8.0.210.0030.00316.93
8.0.200.0070.00017.00
8.0.190.0070.00017.05
8.0.180.0040.00416.85
8.0.170.0040.00416.79
8.0.160.0070.00016.88
8.0.150.0000.00816.75
8.0.140.0000.00716.89
8.0.130.0060.00013.38
8.0.120.0040.00416.89
8.0.110.0040.00417.02
8.0.100.0040.00416.77
8.0.90.0030.00616.80
8.0.80.0090.00516.90
8.0.70.0040.00416.88
8.0.60.0000.00816.95
8.0.50.0080.00016.82
8.0.30.0130.01017.26
8.0.20.0100.01317.30
8.0.10.0050.00317.04
8.0.00.0000.01916.98
7.4.330.0060.00015.55
7.4.320.0000.00616.59
7.4.300.0040.00416.72
7.4.290.0070.00016.48
7.4.280.0030.00616.38
7.4.270.0030.00316.64
7.4.260.0050.00013.32
7.4.250.0070.00016.50
7.4.240.0040.00416.59
7.4.230.0030.00316.72
7.4.220.0020.00516.59
7.4.210.0080.00616.67
7.4.200.0030.00516.33
7.4.140.0080.01117.86
7.4.130.0100.00616.52
7.4.120.0090.00916.55
7.4.110.0090.00916.44
7.4.100.0120.00616.61
7.4.90.0030.01616.63
7.4.80.0070.01319.39
7.4.70.0090.00916.59
7.4.60.0110.00816.43
7.4.50.0040.00816.49
7.4.40.0060.01016.45
7.4.00.0030.01314.95
7.3.330.0070.00016.31
7.3.320.0000.00513.26
7.3.310.0000.00716.39
7.3.300.0000.00716.29
7.3.290.0120.00516.36
7.3.280.0070.01016.34
7.3.260.0120.00616.41
7.3.240.0080.01016.48
7.3.230.0100.00716.59
7.3.210.0090.00916.62
7.3.200.0060.01016.55
7.3.190.0130.00316.63
7.3.180.0000.01616.42
7.3.170.0120.00916.69
7.3.160.0070.00816.58
7.3.120.0120.00814.70
7.3.110.0110.01114.80
7.3.100.0070.00715.03
7.3.90.0060.01015.07
7.3.80.0080.00814.88
7.3.70.0100.00714.95
7.3.60.0090.00614.83
7.3.50.0100.00614.64
7.3.40.0110.00714.80
7.3.30.0070.00814.69
7.3.20.0060.01215.76
7.3.10.0080.00815.74
7.3.00.0120.00415.73
7.2.330.0110.00616.72
7.2.320.0030.01416.76
7.2.310.0060.01416.82
7.2.300.0090.00916.73
7.2.290.0000.01716.61
7.2.240.0070.01314.88
7.2.230.0090.00615.33
7.2.220.0050.00815.15
7.2.210.0060.01214.79
7.2.200.0100.00615.12
7.2.190.0080.00715.10
7.2.180.0060.01015.03
7.2.170.0050.01015.15
7.2.160.0050.01214.94
7.2.150.0110.00715.98
7.2.140.0520.01216.05
7.2.130.0150.00815.96
7.2.120.0080.01016.10
7.2.110.0200.00516.04
7.2.100.0150.00716.14
7.2.90.0140.00716.18
7.2.80.1150.00315.88
7.2.70.0130.01116.04
7.2.60.0110.01215.86
7.2.50.0140.00515.91
7.2.40.0090.01116.11
7.2.30.0050.01216.01
7.2.20.0070.01016.14
7.2.10.0100.00916.17
7.2.00.0070.00915.89
7.1.330.0060.01315.90
7.1.320.0090.00714.93
7.1.310.0080.00914.92
7.1.300.0080.00715.04
7.1.290.0070.01014.77
7.1.280.0110.00714.88
7.1.270.0630.00614.96
7.1.260.0080.01014.92
7.1.250.0080.00914.67

preferences:
48.84 ms | 400 KiB | 5 Q