3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*$menu = array( array(1,3,'Wurm 1.1', 2, 10), array(2,6,'Vogel 2.1', 2, 30), array(3,0,'Tiger 1', 1, 10), array(4,6,'Hund 2.2', 2, 40), array(5,3,'Katze 1.2', 2, 11), array(6,0,'Pferd 2', 1, 20), array(7,1,'Baer 1.1.1', 3, 0), array(8,3,'Schwein 1.3', 2, 12), array(9,4,'Esel 2.2.1', 3, 0), ); // Algorithmus hier $result = array(); var_dump($result == $target); */ $items = array( array( 'mid' => 1, // Menuid 'pid' => 3, // parentid 'title' => 'Wurm 1.1', // title 'level' => 2, // level 'sid' => 10 // sortid ), array( 'mid' => 2, // Menuid 'pid' => 6, // parentid 'title' => 'Vogel 2.1', // title 'level' => 2, // level 'sid' => 30 // sortid ), array( 'mid' => 3, // Menuid 'pid' => 0, // parentid 'title' => 'Tiger 1', // title 'level' => 1, // level 'sid' => 10 // sortid ), array( 'mid' => 4, // Menuid 'pid' => 6, // parentid 'title' => 'Hund 2.2', // title 'level' => 2, // level 'sid' => 40 // sortid ), array( 'mid' => 5, // Menuid 'pid' => 3, // parentid 'title' => 'Katze 1.2', // title 'level' => 2, // level 'sid' => 11 // sortid ), array( 'mid' => 6, // Menuid 'pid' => 0, // parentid 'title' => 'Pferd 2', // title 'level' => 1, // level 'sid' => 20 // sortid ), array( 'mid' => 7, // Menuid 'pid' => 1, // parentid 'title' => 'Baer 1.1.1', // title 'level' => 3, // level 'sid' => 0 // sortid ), array( 'mid' => 8, // Menuid 'pid' => 3, // parentid 'title' => 'Schwein 1.3', // title 'level' => 2, // level 'sid' => 12 // sortid ), array( 'mid' => 9, // Menuid 'pid' => 4, // parentid 'title' => 'Esel 2.2.1', // title 'level' => 3, // level 'sid' => 0 // sortid ) ); function listItems($arr=array(), $pid=0, $level=1) { $result=''; foreach ($arr as $key => $item) { if (!in_array($pid, $item)) continue; if (($item['pid'] == $pid) && ($item['level'] == $level)) { $result .= $item['title'] . '>>' . listItems($arr, $item['mid'], ($level+1)); } } return $result; } listItems($items); /* foreach($items as $item){ } function array_msort($array, $cols) { $colarr = array(); foreach ($cols as $col => $order) { $colarr[$col] = array(); foreach ($array as $k => $row) { $colarr[$col]['_'.$k] = strtolower($row[$col]); } } $eval = 'array_multisort('; foreach ($cols as $col => $order) { $eval .= '$colarr[\''.$col.'\'],'.$order.','; } $eval = substr($eval,0,-1).');'; eval($eval); $ret = array(); foreach ($colarr as $col => $arr) { foreach ($arr as $k => $v) { $k = substr($k,1); if (!isset($ret[$k])) $ret[$k] = $array[$k]; $ret[$k][$col] = $array[$k][$col]; } } return $ret; } function listItems($items, $level=0, $child=false, $pid=0) { array_msort($items, array(4 => SORT_DESC)); $rest = ''; foreach($items as $item) { if ($item[3] != $level) { continue; } if ($child == false) { $rest .= '<li>'. $item[2] .'<ul>'. listItems($items, $level+1, true, $item[0]) .'</ul></li>'; } else { if ($pid == $item[1]) { $rest .= '<li>'. $item[2] .'<ul>'. listItems($items, $level+1, true, $item[0]) .'</ul></li>'; } } } return '<ul>' . $rest . '</ul>'; } echo listItems($navitems);*/

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.0070.01018.43
8.3.50.0100.00921.88
8.3.40.0090.00918.58
8.3.30.0110.00319.16
8.3.20.0020.00520.38
8.3.10.0040.00421.78
8.3.00.0040.00419.38
8.2.180.0080.01218.53
8.2.170.0120.00322.96
8.2.160.0100.00320.26
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0040.00419.67
8.2.110.0100.00019.16
8.2.100.0040.00817.63
8.2.90.0040.00419.34
8.2.80.0090.00017.97
8.2.70.0060.00317.63
8.2.60.0000.00918.05
8.2.50.0000.00818.07
8.2.40.0040.00420.01
8.2.30.0060.00318.13
8.2.20.0070.00017.82
8.2.10.0040.00418.14
8.2.00.0040.00417.75
8.1.280.0160.00625.92
8.1.270.0090.00019.00
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.18
8.1.230.0090.00317.66
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0030.00617.35
8.1.190.0040.00417.25
8.1.180.0030.00618.10
8.1.170.0050.00320.32
8.1.160.0050.00322.03
8.1.150.0000.00718.88
8.1.140.0040.00417.51
8.1.130.0000.00717.75
8.1.120.0050.00217.48
8.1.110.0040.00417.48
8.1.100.0080.00017.42
8.1.90.0000.00717.44
8.1.80.0050.00217.52
8.1.70.0070.00017.35
8.1.60.0000.00817.46
8.1.50.0000.00817.45
8.1.40.0040.00417.50
8.1.30.0030.00517.69
8.1.20.0030.00617.50
8.1.10.0000.00717.54
8.1.00.0070.00017.37
8.0.300.0040.00418.77
8.0.290.0030.00616.63
8.0.280.0030.00618.45
8.0.270.0030.00317.27
8.0.260.0030.00317.27
8.0.250.0030.00317.05
8.0.240.0040.00417.02
8.0.230.0000.00716.87
8.0.220.0070.00016.92
8.0.210.0040.00416.93
8.0.200.0060.00016.98
8.0.190.0040.00416.86
8.0.180.0070.00016.88
8.0.170.0000.00816.94
8.0.160.0070.00016.83
8.0.150.0000.00716.81
8.0.140.0040.00416.91
8.0.130.0000.00513.29
8.0.120.0040.00416.89
8.0.110.0000.00716.86
8.0.100.0000.00716.94
8.0.90.0050.00216.83
8.0.80.0130.00916.91
8.0.70.0050.00516.82
8.0.60.0020.00516.85
8.0.50.0050.00316.98
8.0.30.0140.00717.17
8.0.20.0170.01917.40
8.0.10.0020.00516.92
8.0.00.0080.00816.75
7.4.330.0050.00015.15
7.4.320.0070.00016.53
7.4.300.0070.00016.66
7.4.290.0030.00316.52
7.4.280.0000.00816.61
7.4.270.0040.00416.50
7.4.260.0080.00016.37
7.4.250.0070.00016.47
7.4.240.0000.00816.56
7.4.230.0070.00016.38
7.4.220.0090.01316.62
7.4.210.0120.00616.65
7.4.200.0070.00016.71
7.4.160.0130.00316.60
7.4.150.0060.01017.40
7.4.140.0080.00817.86
7.4.130.0090.00916.55
7.4.120.0090.01016.61
7.4.110.0120.00616.40
7.4.100.0090.00916.60
7.4.90.0060.01216.41
7.4.80.0130.01019.39
7.4.70.0100.00716.65
7.4.60.0090.00616.45
7.4.50.0000.00516.62
7.4.40.0130.00716.48
7.4.30.0120.01116.48
7.4.00.0100.00314.99
7.3.330.0000.00713.37
7.3.320.0040.01213.38
7.3.310.0030.00316.36
7.3.300.0030.00316.38
7.3.290.0130.00316.38
7.3.280.0110.00516.34
7.3.270.0110.00717.40
7.3.260.0120.00616.34
7.3.250.0150.00316.63
7.3.240.0100.00716.39
7.3.230.0000.01816.39
7.3.210.0060.00916.29
7.3.200.0140.00619.39
7.3.190.0030.01316.38
7.3.180.0040.01116.52
7.3.170.0080.00816.39
7.3.160.0070.01016.39
7.2.330.0000.01816.67
7.2.320.0070.01116.55
7.2.310.0130.01016.55
7.2.300.0080.01616.45
7.2.290.0100.01016.72
7.2.60.0090.00216.55
7.2.00.0070.00719.64
7.1.200.0060.00315.89
7.1.100.0080.00818.11
7.1.70.0070.00017.21
7.1.60.0080.00819.50
7.1.50.0180.00716.65
7.1.00.0100.07022.54
7.0.200.0070.01016.88
7.0.140.0000.07021.99
7.0.60.0130.07719.97
7.0.50.0100.07717.86
7.0.40.0130.08720.13
7.0.30.0330.07720.16
7.0.20.0270.04320.09
7.0.10.0330.06320.08
7.0.00.0070.07320.16
5.6.280.0030.07321.09
5.6.210.0170.05720.75
5.6.200.0100.08018.12
5.6.190.0100.05720.46
5.6.180.0200.03720.39
5.6.170.0270.05020.40
5.6.160.0070.04020.48
5.6.150.0070.04718.19
5.6.140.0000.04718.19
5.6.130.0130.07718.15
5.6.120.0130.08321.05
5.6.110.0200.06021.10
5.6.100.0100.07721.12
5.6.90.0100.04321.11
5.6.80.0130.07720.38
5.6.70.0070.08320.41
5.5.350.0100.06020.39
5.5.340.0070.07718.04
5.5.330.0200.06720.31
5.5.320.0200.08020.26
5.5.310.0170.09020.20
5.5.300.0070.05718.05
5.5.290.0100.08317.94
5.5.280.0170.07720.78
5.5.270.0070.08320.73
5.5.260.0170.07320.77
5.5.250.0030.08720.80
5.5.240.0200.05720.20
5.4.450.0230.05019.61
5.4.440.0270.07319.48
5.4.430.0200.08019.32
5.4.420.0230.04719.48
5.4.410.0170.04319.32
5.4.400.0230.03018.88
5.4.390.0130.04319.14
5.4.380.0270.06319.19
5.4.370.0200.06719.06
5.4.360.0130.05319.05
5.4.350.0270.07018.87
5.4.340.0130.04719.09
5.4.320.0300.06719.20
5.4.310.0230.03319.09
5.4.300.0270.03319.23
5.4.290.0270.05719.21
5.4.280.0200.04718.95
5.4.270.0200.03319.14
5.4.260.0200.04718.94
5.4.250.0200.03718.93
5.4.240.0300.04018.99
5.4.230.0230.03318.86
5.4.220.0230.04719.21
5.4.210.0300.04719.08
5.4.200.0270.05719.18
5.4.190.0170.04719.12
5.4.180.0200.04018.96
5.4.170.0270.03019.14
5.4.160.0170.05019.11
5.4.150.0230.05018.96
5.4.140.0200.04316.63
5.4.130.0300.05716.35
5.4.120.0270.04016.41
5.4.110.0230.03316.54
5.4.100.0300.06316.46
5.4.90.0200.03316.30
5.4.80.0270.02716.54
5.4.70.0230.03316.35
5.4.60.0230.02716.25
5.4.50.0330.06316.54
5.4.40.0200.03716.49
5.4.30.0230.04316.33
5.4.20.0300.03316.48
5.4.10.0230.03316.55
5.4.00.0230.03015.80
5.3.290.0130.04314.67
5.3.280.0200.04014.52
5.3.270.0200.03714.84
5.3.260.0270.05314.63
5.3.250.0330.04714.59
5.3.240.0230.04314.63
5.3.230.0270.05014.73
5.3.220.0200.03714.64
5.3.210.0270.06314.60
5.3.200.0200.05714.58
5.3.190.0170.06014.55
5.3.180.0170.04714.73
5.3.170.0230.05714.60
5.3.160.0230.04314.69
5.3.150.0270.04014.59
5.3.140.0200.04714.47
5.3.130.0230.06714.81
5.3.120.0270.07014.57
5.3.110.0270.04314.79
5.3.100.0300.03714.13
5.3.90.0270.04314.00
5.3.80.0300.06714.25
5.3.70.0270.06714.14
5.3.60.0170.04714.02
5.3.50.0230.04013.97
5.3.40.0270.07314.19
5.3.30.0270.06314.07
5.3.20.0270.06713.61
5.3.10.0200.04013.59
5.3.00.0230.06013.63
5.2.170.0170.03311.09
5.2.160.0230.05311.14
5.2.150.0270.05311.22
5.2.140.0200.06311.25
5.2.130.0200.03711.04
5.2.120.0170.02711.05
5.2.110.0170.06311.03
5.2.100.0200.02711.24
5.2.90.0200.02711.02
5.2.80.0170.06011.09
5.2.70.0170.03711.17
5.2.60.0200.03311.22
5.2.50.0170.06011.15
5.2.40.0170.05710.93
5.2.30.0170.04011.10
5.2.20.0130.03310.88
5.2.10.0200.05710.84
5.2.00.0170.03010.98
5.1.60.0230.0439.96
5.1.50.0100.0309.99
5.1.40.0200.0509.96
5.1.30.0200.04710.46
5.1.20.0130.05710.32
5.1.10.0170.0309.99
5.1.00.0230.04310.24
5.0.50.0070.0309.96
5.0.40.0070.0309.96
5.0.30.0100.0709.96
5.0.20.0170.0409.96
5.0.10.0030.0339.96
5.0.00.0100.0579.96
4.4.90.0070.0279.96
4.4.80.0100.0239.96
4.4.70.0130.0179.96
4.4.60.0100.0339.96
4.4.50.0100.0179.96
4.4.40.0130.0309.96
4.4.30.0030.0239.96
4.4.20.0070.0239.96
4.4.10.0100.0209.96
4.4.00.0070.0479.96
4.3.110.0100.0339.96
4.3.100.0130.0179.96
4.3.90.0170.0309.96
4.3.80.0100.0339.96
4.3.70.0130.0179.96
4.3.60.0070.0179.96
4.3.50.0130.0279.96
4.3.40.0130.0279.96
4.3.30.0000.0209.96
4.3.20.0100.0279.96
4.3.10.0070.0339.96
4.3.00.0030.0179.96

preferences:
51.5 ms | 401 KiB | 5 Q