3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( 0 => array( "text" => "eventyrer", "children"=> array( 4 => array( "text" => "news", "children"=> array( 1=> array("text"=>"a") ) ), 5 => array( "text" => "nyheter", "children"=> array( 1=> array("text"=>"b") ) ) ) ), 1 => array( "text" => "eventyrer2017", "children"=> array( 6 => array( "text" => "news", "children"=> array( 1=> array("text"=>"c") ) ), 8 => array( "text" => "nyheter", "children"=> array( 1=> array("text"=>"d") ) ) ) ) ); class Tree { private $data; private $html; public function buildTree(array $data, $parent_id) { $this->data = $data; $this->html = []; foreach ($data as $key => $value) { $this->process($key, $value); } return $this->html; } private function process($parentKey, $value) { var_dump($value); $this->html[$parentKey] = $value['text']; if (array_key_exists('children', $value) && count($value['children'])) { $this->html[$parentKey] .= '/'; $this->process($parentKey, $value['children']); } } } $tree = new Tree(); $ul = $tree->buildTree($arr, 0); var_dump( $ul);

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.0110.00818.40
8.3.50.0130.00618.16
8.3.40.0080.01118.79
8.3.30.0120.00818.89
8.3.20.0050.00319.30
8.3.10.0040.00421.89
8.3.00.0070.00320.71
8.2.180.0120.00318.41
8.2.170.0130.01022.96
8.2.160.0060.00820.22
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0000.00819.83
8.2.120.0050.00326.35
8.2.110.0000.01019.36
8.2.100.0090.00318.03
8.2.90.0060.00317.75
8.2.80.0030.00617.97
8.2.70.0060.00317.92
8.2.60.0000.00818.16
8.2.50.0050.00318.10
8.2.40.0040.00419.50
8.2.30.0040.00419.20
8.2.20.0090.00318.01
8.2.10.0070.00018.01
8.2.00.0080.00017.79
8.1.280.0110.00425.92
8.1.270.0080.00022.09
8.1.260.0040.01526.35
8.1.250.0080.00028.09
8.1.240.0000.00922.81
8.1.230.0030.00917.66
8.1.220.0050.00317.76
8.1.210.0030.00618.77
8.1.200.0030.00717.35
8.1.190.0080.00017.38
8.1.180.0040.00418.10
8.1.170.0000.00818.48
8.1.160.0000.00718.90
8.1.150.0050.00218.82
8.1.140.0040.00422.15
8.1.130.0030.00320.16
8.1.120.0020.00517.51
8.1.110.0050.00317.39
8.1.100.0050.00217.39
8.1.90.0030.00517.43
8.1.80.0030.00717.44
8.1.70.0030.00317.36
8.1.60.0070.00417.48
8.1.50.0030.00617.42
8.1.40.0000.00817.41
8.1.30.0080.00317.49
8.1.20.0040.00417.60
8.1.10.0030.00517.36
8.1.00.0030.00517.42
8.0.300.0000.00818.77
8.0.290.0040.00416.75
8.0.280.0040.00418.32
8.0.270.0030.00317.27
8.0.260.0070.00018.40
8.0.250.0000.00717.00
8.0.240.0040.00417.04
8.0.230.0000.00717.04
8.0.220.0030.01016.94
8.0.210.0040.00416.86
8.0.200.0000.00716.88
8.0.190.0040.00417.01
8.0.180.0000.00816.92
8.0.170.0060.00316.91
8.0.160.0050.00216.92
8.0.150.0000.00816.87
8.0.140.0000.00816.81
8.0.130.0000.00613.36
8.0.120.0040.00416.85
8.0.110.0030.00616.89
8.0.100.0040.00416.79
8.0.90.0050.00217.04
8.0.80.0050.01216.96
8.0.70.0000.00816.78
8.0.60.0050.00216.79
8.0.50.0040.00416.96
8.0.30.0090.00916.88
8.0.20.0200.00317.40
8.0.10.0000.00716.96
8.0.00.0140.01016.83
7.4.330.0000.00515.55
7.4.320.0030.00316.53
7.4.300.0030.00316.42
7.4.290.0040.00416.46
7.4.280.0000.00716.52
7.4.270.0040.00416.67
7.4.260.0070.00016.55
7.4.250.0040.00416.47
7.4.240.0060.00316.62
7.4.230.0000.00816.49
7.4.220.0030.00516.41
7.4.210.0070.01316.62
7.4.200.0030.00316.59
7.4.160.0130.00616.42
7.4.140.0140.00917.86
7.4.130.0120.00616.59
7.4.120.0100.00916.59
7.4.110.0200.00316.63
7.4.100.0120.00616.46
7.4.90.0100.01016.61
7.4.80.0060.01219.39
7.4.70.0110.00716.52
7.4.60.0150.00316.51
7.4.50.0070.00816.54
7.4.40.0080.01216.39
7.4.00.0060.00914.89
7.3.330.0030.00313.21
7.3.320.0030.00313.36
7.3.310.0050.00316.43
7.3.300.0030.00316.31
7.3.290.0050.00216.48
7.3.280.0080.01216.41
7.3.260.0130.00916.43
7.3.240.0090.01016.43
7.3.230.0130.00516.58
7.3.210.0140.00816.50
7.3.200.0110.00616.68
7.3.190.0060.01516.57
7.3.180.0130.00316.57
7.3.170.0110.00716.43
7.3.160.0090.00916.34
7.3.120.0000.01515.19
7.3.110.0060.00915.05
7.3.100.0070.01014.98
7.3.90.0070.01015.04
7.3.80.0060.01014.89
7.3.70.0070.01014.77
7.3.60.0080.00814.89
7.3.50.0070.00714.70
7.3.40.0030.01414.85
7.3.30.0070.00414.94
7.3.20.0030.01316.73
7.3.10.0120.00316.73
7.3.00.0000.01016.88
7.2.330.0130.00716.75
7.2.320.0060.01316.45
7.2.310.0090.00916.68
7.2.300.0150.00416.80
7.2.290.0040.01516.45
7.2.240.0100.01015.01
7.2.230.0070.01015.08
7.2.220.0160.00015.05
7.2.210.0100.00314.88
7.2.200.0000.01115.11
7.2.190.0030.01315.09
7.2.180.0040.00714.80
7.2.170.0080.00315.12
7.2.160.0030.01014.86
7.2.150.0030.00716.92
7.2.140.0040.01416.89
7.2.130.0090.00616.93
7.2.120.0000.01017.07
7.2.110.0500.01315.93
7.2.100.0190.01215.73
7.2.90.0180.00315.97
7.2.80.0200.00715.56
7.2.70.0150.00515.82
7.2.60.0170.01216.01
7.2.50.0180.01016.13
7.2.40.0190.01116.13
7.2.30.0150.00515.89
7.2.20.0160.00615.94
7.2.10.0160.00815.90
7.2.00.0180.01115.80
7.1.330.0060.00915.68
7.1.320.0000.01215.76
7.1.310.0070.01016.00
7.1.300.0070.00316.01
7.1.290.0000.01215.84
7.1.280.0130.00015.83
7.1.270.0060.00915.59
7.1.260.0060.00915.84
7.1.250.0070.00715.85
7.1.230.0430.00613.90
7.1.220.0340.01013.82
7.1.210.0240.00613.84
7.1.200.0280.00613.94
7.1.190.0240.00313.94
7.1.180.0190.01213.90
7.1.170.0400.00413.79
7.1.160.0300.00313.92
7.1.150.0300.01013.93
7.1.140.0230.01013.81
7.1.130.1050.01313.80
7.1.120.0240.00613.62
7.1.110.0210.00713.88
7.1.100.0320.00614.01
7.1.90.0290.00413.88
7.1.80.0280.00013.74
7.1.70.0240.00413.73
7.1.60.0420.00731.73
7.1.50.0420.01031.93
7.1.40.0390.01331.94
7.1.30.0380.01631.81
7.1.20.0410.00631.75
7.1.10.0230.00713.90
7.1.00.0190.01013.91
5.6.380.0030.01314.52

preferences:
57.19 ms | 401 KiB | 5 Q