3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tree = [ 0 => [ 'name' => 'root', 'data' => 0, 'children' => [ '1' => [ 'name' => 'Auto', 'data' => 0, 'children' => [ '2' => [ 'name' => 'Tyres', 'data' => 0, 'children' => [], ], '3' => [ 'name' => 'Audio', 'data' => 1, 'children' => [], ], ], ], '4' => [ 'name' => 'Dishes', 'data' => 0, 'children' => [ '5' => [ 'name' => 'Forks', 'data' => 0, 'children' => [], ], '6' => [ 'name' => 'Knives', 'data' => 0, 'children' => [ '7' => [ 'name' => 'Stainless steel', 'data' => 0, 'children' => [], ], '8' => [ 'name' => 'Silver', 'data' => 0, 'children' => [], ], ], ], ], ], ] ] ]; #var_dump($tree); function reduceTree($tree) { foreach ($tree['children'] as $key => $value) { if ($value['children']) { $tree['children'][$key] = reduceTree($value); } if (!$tree['data'] && !$tree['children']) { unset($tree['children'][$key]); } } return $tree; } $new = reduceTree($tree[0]); var_dump($new);

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.30.0100.00618.83
8.3.20.0090.00020.20
8.3.10.0040.00421.76
8.3.00.0040.00423.48
8.2.160.0040.01120.93
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0040.00422.21
8.2.120.0040.00426.35
8.2.110.0000.00920.91
8.2.100.0040.00818.22
8.2.90.0080.00018.96
8.2.80.0080.00018.04
8.2.70.0040.00417.75
8.2.60.0050.00318.04
8.2.50.0040.00418.10
8.2.40.0050.00322.32
8.2.30.0020.00519.28
8.2.20.0040.00418.19
8.2.10.0040.00418.20
8.2.00.0050.00318.29
8.1.270.0080.00023.96
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00322.10
8.1.230.0060.00618.76
8.1.220.0000.00917.74
8.1.210.0030.00518.77
8.1.200.0050.00517.48
8.1.190.0080.00017.53
8.1.180.0040.00418.10
8.1.170.0000.00822.07
8.1.160.0000.00718.85
8.1.150.0020.00521.91
8.1.140.0000.00719.49
8.1.130.0050.00219.02
8.1.120.0000.00717.42
8.1.110.0080.00017.38
8.1.100.0080.00017.52
8.1.90.0070.00317.46
8.1.80.0070.00417.52
8.1.70.0030.00317.51
8.1.60.0040.00417.50
8.1.50.0050.00317.58
8.1.40.0030.00517.52
8.1.30.0080.00017.59
8.1.20.0050.00517.63
8.1.10.0030.00517.53
8.1.00.0030.00617.30
8.0.300.0070.00018.77
8.0.290.0040.00416.88
8.0.280.0000.00718.56
8.0.270.0000.00817.34
8.0.260.0000.00617.20
8.0.250.0070.00016.98
8.0.240.0070.00417.00
8.0.230.0080.00016.87
8.0.220.0000.00816.89
8.0.210.0040.00416.88
8.0.200.0060.00016.93
8.0.190.0000.00817.01
8.0.180.0000.00716.89
8.0.170.0040.00416.98
8.0.160.0000.00716.79
8.0.150.0000.00716.88
8.0.140.0050.00316.84
8.0.130.0030.00313.37
8.0.120.0070.00016.84
8.0.110.0040.00416.89
8.0.100.0000.00716.93
8.0.90.0000.00716.85
8.0.80.0090.00616.88
8.0.70.0040.00416.89
8.0.60.0050.00216.85
8.0.50.0040.00416.95
8.0.30.0100.00817.18
8.0.20.0130.00717.40
8.0.10.0070.00017.04
8.0.00.0180.00416.71
7.4.330.0040.00415.55
7.4.320.0000.00616.52
7.4.300.0040.00416.58
7.4.290.0030.00316.52
7.4.280.0000.00816.48
7.4.270.0070.00016.61
7.4.260.0070.00316.60
7.4.250.0030.00316.57
7.4.240.0050.00216.44
7.4.230.0030.00316.49
7.4.220.0110.00716.63
7.4.210.0060.01016.56
7.4.200.0040.00316.58
7.4.160.0120.00616.63
7.4.150.0180.00017.40
7.4.140.0150.00717.86
7.4.130.0140.00716.43
7.4.120.0130.00816.57
7.4.110.0090.00916.50
7.4.100.0150.00316.60
7.4.90.0090.00916.34
7.4.80.0040.01519.39
7.4.70.0070.01116.49
7.4.60.0100.00716.53
7.4.50.0030.01016.31
7.4.40.0100.01016.60
7.4.30.0100.00716.45
7.4.10.0030.01714.87
7.4.00.0090.00815.01
7.3.330.0030.00313.16
7.3.320.0000.00513.35
7.3.310.0040.00416.24
7.3.300.0030.00516.38
7.3.290.0040.00416.22
7.3.280.0100.00916.27
7.3.270.0070.01517.40
7.3.260.0090.01316.54
7.3.250.0120.00816.58
7.3.240.0090.01016.50
7.3.230.0150.00616.57
7.3.210.0060.01216.41
7.3.200.0140.01016.45
7.3.190.0090.01016.49
7.3.180.0060.01216.44
7.3.170.0060.01216.49
7.3.160.0030.01316.47
7.3.130.0090.00914.68
7.3.120.0090.00914.81
7.3.110.0150.00715.08
7.3.100.0070.00715.13
7.3.90.0060.00914.85
7.3.80.0070.01014.80
7.3.70.0030.01214.69
7.3.60.0060.00314.91
7.3.50.0030.01514.81
7.3.40.0040.01214.61
7.3.30.0070.00314.99
7.3.20.0030.01016.70
7.3.10.0080.00916.54
7.3.00.0070.01016.56
7.2.330.0030.01516.77
7.2.320.0150.00416.63
7.2.310.0120.00416.48
7.2.300.0090.01616.78
7.2.290.0030.01616.80
7.2.260.0090.00715.29
7.2.250.0120.00814.99
7.2.240.0090.00614.74
7.2.230.0030.01415.09
7.2.220.0030.01215.33
7.2.210.0120.00614.62
7.2.200.0030.00714.97
7.2.190.0100.01015.07
7.2.180.0030.01315.28
7.2.170.0100.00615.04
7.2.160.0030.01014.86
7.2.150.0070.00316.95
7.2.140.0060.00916.93
7.2.130.0050.00916.69
7.2.120.0110.00816.67
7.2.110.0110.00616.78
7.2.100.0140.00316.56
7.2.90.0120.00316.75
7.2.80.0050.01416.78
7.2.70.0090.01116.87
7.2.60.0090.01016.97
7.2.50.0120.00416.82
7.2.40.0120.00516.94
7.2.30.0050.00816.59
7.2.20.0090.00816.73
7.2.10.0110.00816.96
7.2.00.0050.00816.94
7.1.330.0000.01515.66
7.1.320.0110.00415.86
7.1.310.0000.01315.95
7.1.300.0110.00415.51
7.1.290.0070.01015.83
7.1.280.0070.00416.02
7.1.270.0110.00415.91
7.1.260.0000.01315.87
7.1.250.0080.00615.51
7.1.240.0000.01315.71
7.1.230.0000.00915.73
7.1.220.0070.00715.80
7.1.210.0040.01115.97
7.1.200.0010.00815.95
7.1.190.0100.00715.89
7.1.180.0070.00715.58
7.1.170.0000.01115.88
7.1.160.0060.00615.55
7.1.150.0030.01315.88
7.1.140.0000.00915.83
7.1.130.0090.00615.84
7.1.120.0090.00315.68
7.1.110.0000.01215.79
7.1.100.0000.01315.50
7.1.90.0070.00715.89
7.1.80.0030.00915.82
7.1.70.0030.00916.55
7.1.60.0090.00416.49
7.1.50.0000.00915.90
7.1.40.0110.01024.99
7.1.30.0140.01125.12
7.1.20.0090.01425.05
7.1.10.0080.00516.22
7.1.00.0060.00916.34
7.0.330.0130.00315.60
7.0.320.0030.01015.20
7.0.310.0030.00615.55
7.0.300.0060.00615.43
7.0.290.0070.00715.20
7.0.280.0110.00415.25
7.0.270.0110.00415.56
7.0.260.0000.01315.35
7.0.250.0090.00315.43
7.0.240.0120.00315.27
7.0.230.0070.00715.25
7.0.220.0060.00315.46
7.0.210.0030.01015.53
7.0.200.0050.00816.02
7.0.190.0080.00015.56
7.0.180.0080.00915.85
7.0.170.0030.01315.88
7.0.160.0030.01315.88
7.0.150.0040.00915.74
7.0.140.0070.00515.82
7.0.130.0050.01015.91
7.0.120.0020.01216.02
7.0.110.0040.00715.83
7.0.100.0050.00815.77
7.0.90.0080.00615.90
7.0.80.0120.00315.91
7.0.70.0060.00715.95
7.0.60.0070.00815.72
7.0.50.0020.00916.04
7.0.40.0070.00715.07
7.0.30.0080.00714.85
7.0.20.0060.00814.95
7.0.10.0050.00814.93
7.0.00.0050.01214.84
5.6.400.0030.01014.30
5.6.390.0030.01414.36
5.6.380.0040.00414.83
5.6.370.0110.00014.77
5.6.360.0050.00814.79
5.6.350.0060.00314.55
5.6.340.0000.01214.75
5.6.330.0090.00614.52
5.6.320.0090.00014.04
5.6.310.0130.00314.20
5.6.300.0090.00314.83
5.6.290.0030.01114.62
5.6.280.0030.00814.39
5.6.270.0070.00714.41
5.6.260.0060.00914.55
5.6.250.0070.01014.31
5.6.240.0070.01014.26
5.6.230.0060.01014.32
5.6.220.0030.01014.57
5.6.210.0030.01014.43
5.6.200.0030.01314.49
5.6.190.0040.00914.38
5.6.180.0060.00914.45
5.6.170.0080.00414.44
5.6.160.0070.01014.40
5.6.150.0040.01614.51
5.6.140.0120.00314.54
5.6.130.0060.00614.43
5.6.120.0090.00614.33
5.6.110.0060.00314.26
5.6.100.0060.00614.54
5.6.90.0030.00914.46
5.6.80.0040.00814.41
5.6.70.0100.00714.14
5.6.60.0000.01114.33
5.6.50.0030.00614.31
5.6.40.0090.00314.08
5.6.30.0030.01414.68
5.6.20.0060.00614.36
5.6.10.0070.00714.36
5.6.00.0070.00714.52

preferences:
29.49 ms | 401 KiB | 5 Q