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) { $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.43
8.3.50.0130.00617.98
8.3.40.0070.00718.93
8.3.30.0150.00018.79
8.3.20.0080.00019.29
8.3.10.0080.00021.81
8.3.00.0030.00520.68
8.2.180.0080.00818.66
8.2.170.0110.00318.81
8.2.160.0040.01122.96
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0030.00519.77
8.2.120.0030.00526.35
8.2.110.0000.00920.48
8.2.100.0090.00317.91
8.2.90.0060.00318.00
8.2.80.0000.00817.97
8.2.70.0040.00418.05
8.2.60.0060.00318.16
8.2.50.0000.00818.10
8.2.40.0040.00419.23
8.2.30.0000.00719.30
8.2.20.0070.00418.13
8.2.10.0040.00418.06
8.2.00.0000.00817.77
8.1.280.0140.00025.92
8.1.270.0000.00821.99
8.1.260.0060.01326.35
8.1.250.0030.00528.09
8.1.240.0080.00024.01
8.1.230.0060.00620.98
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0000.01017.36
8.1.190.0090.00017.23
8.1.180.0080.00018.10
8.1.170.0050.00318.60
8.1.160.0050.00318.90
8.1.150.0000.00818.80
8.1.140.0000.00722.15
8.1.130.0070.00020.30
8.1.120.0000.00817.43
8.1.110.0070.00017.43
8.1.100.0040.00417.46
8.1.90.0070.00017.47
8.1.80.0080.00017.52
8.1.70.0030.00517.48
8.1.60.0080.00317.55
8.1.50.0000.00817.54
8.1.40.0040.00417.41
8.1.30.0030.01017.56
8.1.20.0090.00017.55
8.1.10.0040.00417.36
8.1.00.0060.00317.37
8.0.300.0050.00218.77
8.0.290.0040.00416.75
8.0.280.0000.00718.39
8.0.270.0030.00317.14
8.0.260.0000.00618.36
8.0.250.0050.00216.93
8.0.240.0000.00717.00
8.0.230.0040.00417.02
8.0.220.0000.00816.99
8.0.210.0030.00316.89
8.0.200.0000.00616.91
8.0.190.0040.00416.94
8.0.180.0060.00317.02
8.0.170.0030.00616.87
8.0.160.0040.00417.02
8.0.150.0060.00316.91
8.0.140.0030.00316.91
8.0.130.0060.00013.44
8.0.120.0070.00016.91
8.0.110.0000.00816.90
8.0.100.0040.00416.78
8.0.90.0050.00216.98
8.0.80.0030.01216.90
8.0.70.0040.00416.75
8.0.60.0070.00016.95
8.0.50.0040.00416.95
8.0.30.0070.01217.13
8.0.20.0100.01017.40
8.0.10.0040.00417.10
8.0.00.0120.01216.90
7.4.330.0000.00615.55
7.4.320.0000.00616.53
7.4.300.0030.00316.64
7.4.290.0070.00016.62
7.4.280.0000.00816.59
7.4.270.0000.00716.57
7.4.260.0030.00316.36
7.4.250.0000.00716.55
7.4.240.0030.00516.54
7.4.230.0030.00316.36
7.4.220.0060.00316.60
7.4.210.0050.01016.59
7.4.200.0060.00016.67
7.4.160.0120.00616.64
7.4.140.0120.00717.86
7.4.130.0150.00416.47
7.4.120.0100.01016.55
7.4.110.0130.00916.52
7.4.100.0030.01316.54
7.4.90.0110.00616.39
7.4.80.0110.00819.39
7.4.70.0130.00316.63
7.4.60.0120.00616.47
7.4.50.0040.01416.56
7.4.40.0150.00716.49
7.4.00.0060.01114.99
7.3.330.0020.00213.27
7.3.320.0000.00513.27
7.3.310.0000.00816.29
7.3.300.0030.00316.28
7.3.290.0030.00316.44
7.3.280.0060.00816.43
7.3.260.0170.00316.52
7.3.240.0120.00516.54
7.3.230.0100.00716.44
7.3.210.0090.00916.46
7.3.200.0070.01016.59
7.3.190.0110.00916.43
7.3.180.0100.00616.39
7.3.170.0100.01316.47
7.3.160.0070.01016.59
7.3.120.0070.01014.96
7.3.110.0070.01114.86
7.3.100.0000.01414.87
7.3.90.0080.00314.93
7.3.80.0060.00814.73
7.3.70.0130.00314.98
7.3.60.0030.01014.79
7.3.50.0030.01014.71
7.3.40.0000.01414.86
7.3.30.0110.00414.55
7.3.20.0030.00616.65
7.3.10.0060.00916.41
7.3.00.0070.01016.86
7.2.330.0120.00616.77
7.2.320.0070.01116.79
7.2.310.0070.01516.81
7.2.300.0100.00616.81
7.2.290.0080.01216.48
7.2.250.0080.00815.01
7.2.240.0080.01115.31
7.2.230.0070.00315.21
7.2.220.0000.01315.10
7.2.210.0040.00715.19
7.2.200.0040.00815.10
7.2.190.0120.00314.96
7.2.180.0080.00315.13
7.2.170.0090.00615.11
7.2.110.0320.00614.90
7.2.100.0330.00014.54
7.2.90.0280.00014.96
7.2.80.0180.00614.61
7.2.70.0250.01414.73
7.2.60.0290.00415.06
7.2.50.0190.00615.16
7.2.40.0380.00315.03
7.2.30.0270.00315.00
7.2.20.0330.01114.93
7.2.10.0210.00914.93
7.2.00.0220.00914.90
7.1.330.0070.00715.75
7.1.320.0070.00315.56
7.1.310.0130.00015.92
7.1.300.0090.00615.95
7.1.290.0070.00715.84
7.1.280.0040.00415.66
7.1.270.0110.00415.66
7.1.260.0100.00315.87
7.1.230.0230.01013.92
7.1.220.0290.00913.89
7.1.210.0220.00613.92
7.1.200.0160.00713.87
7.1.190.0190.00713.79
7.1.180.0130.01313.64
7.1.170.0160.01313.82
7.1.160.0310.00913.77
7.1.150.0230.00713.89
7.1.140.0310.00813.77
7.1.130.0240.00813.66
7.1.120.0150.00613.96
7.1.110.0250.00613.75
7.1.100.0210.01113.74
7.1.90.0190.01314.06
7.1.80.0260.01313.98
7.1.70.0240.01014.02
7.1.60.0360.01032.04
7.1.50.0270.01832.04
7.1.40.0470.00331.46
7.1.30.0410.01431.90
7.1.20.0300.01231.91
7.1.10.0300.00713.68
7.1.00.0150.01113.79
5.6.380.0110.00814.50

preferences:
46.96 ms | 400 KiB | 5 Q