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=''; if ($level > 9) break; foreach ($arr as $key => $item) { 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)
5.6.280.0070.07021.01
5.6.210.0130.08020.64
5.6.200.0030.05018.18
5.6.190.0030.04320.34
5.6.180.0130.05320.36
5.6.170.0230.04720.55
5.6.160.0000.06720.51
5.6.150.0030.04718.15
5.6.140.0170.03318.28
5.6.130.0200.07318.23
5.6.120.0170.04020.97
5.6.110.0200.06021.08
5.6.100.0070.07321.00
5.6.90.0130.07320.98
5.6.80.0130.08020.52
5.6.70.0100.08020.52
5.5.350.0230.07320.39
5.5.340.0100.07318.09
5.5.330.0230.06720.43
5.5.320.0170.08320.37
5.5.310.0300.07020.30
5.5.300.0000.06718.05
5.5.290.0070.04317.99
5.5.280.0000.09020.88
5.5.270.0030.06020.88
5.5.260.0070.07020.85
5.5.250.0030.08020.60
5.5.240.0100.05020.29
5.4.450.0170.04319.64
5.4.440.0200.03319.32
5.4.430.0170.03719.47
5.4.420.0230.03019.47
5.4.410.0270.03019.32
5.4.400.0130.03719.18
5.4.390.0200.03718.99
5.4.380.0130.04019.20
5.4.370.0130.04019.16
5.4.360.0130.04719.10
5.4.350.0170.04018.85
5.4.340.0200.04019.16
5.4.320.0200.05018.94
5.4.310.0270.03719.26
5.4.300.0300.04319.16
5.4.290.0270.06319.13
5.4.280.0430.05319.13
5.4.270.0200.03718.87
5.4.260.0170.05319.13
5.4.250.0300.07018.97
5.4.240.0230.06718.96
5.4.230.0300.07319.32
5.4.220.0270.07019.03
5.4.210.0270.07018.85
5.4.200.0330.04719.07
5.4.190.0270.07318.84
5.4.180.0300.06319.19
5.4.170.0200.06318.88
5.4.160.0300.07319.14
5.4.150.0230.07319.20
5.4.140.0270.03316.33
5.4.130.0300.04016.41
5.4.120.0270.06716.38
5.4.110.0230.04016.46
5.4.100.0270.02716.28
5.4.90.0130.04016.59
5.4.80.0270.03016.44
5.4.70.0070.04016.58
5.4.60.0130.03316.44
5.4.50.0230.03716.30
5.4.40.0130.04316.54
5.4.30.0270.07316.26
5.4.20.0200.05316.51
5.4.10.0370.02716.25
5.4.00.0170.04015.78
5.3.290.0270.07314.59
5.3.280.0300.04314.52
5.3.270.0270.07014.64
5.3.260.0300.06314.54
5.3.250.0270.05714.57
5.3.240.0170.04314.66
5.3.230.0300.06314.58
5.3.220.0300.03314.49
5.3.210.0230.07314.66
5.3.200.0230.03314.50
5.3.190.0200.03314.55
5.3.180.0330.06014.66
5.3.170.0130.04314.73
5.3.160.0170.03314.74
5.3.150.0130.03714.62
5.3.140.0130.04714.55
5.3.130.0130.05014.49
5.3.120.0170.08014.56
5.3.110.0300.06714.47
5.3.100.0270.03014.05
5.3.90.0270.04714.11
5.3.80.0230.05314.11
5.3.70.0170.04014.04
5.3.60.0230.03013.99
5.3.50.0170.03714.08
5.3.40.0230.07013.89
5.3.30.0200.05013.94
5.3.20.0130.06313.61
5.3.10.0200.07013.78
5.3.00.0170.07013.57
5.2.170.0170.02711.95
5.2.160.0070.03311.95
5.2.150.0170.05711.95
5.2.140.0130.06011.95
5.2.130.0130.06011.95
5.2.120.0130.05311.95
5.2.110.0200.03711.95
5.2.100.0100.05311.95
5.2.90.0130.06011.95
5.2.80.0270.05011.95
5.2.70.0270.05011.95
5.2.60.0170.04711.95
5.2.50.0170.04011.95
5.2.40.0230.04011.95
5.2.30.0170.05011.95
5.2.20.0270.03011.95
5.2.10.0100.04711.95
5.2.00.0270.04011.95
5.1.60.0170.03011.95
5.1.50.0200.02711.95
5.1.40.0170.05311.95
5.1.30.0230.04311.95
5.1.20.0330.04011.95
5.1.10.0200.05011.95
5.1.00.0200.05011.95
5.0.50.0070.04311.95
5.0.40.0130.03011.95
5.0.30.0100.05311.95
5.0.20.0030.04011.95
5.0.10.0100.04311.95
5.0.00.0130.05311.95
4.4.90.0100.02011.95
4.4.80.0130.01711.95
4.4.70.0070.02011.95
4.4.60.0070.03711.95
4.4.50.0100.03311.95
4.4.40.0030.03311.95
4.4.30.0100.01711.95
4.4.20.0270.02011.95
4.4.10.0070.03311.95
4.4.00.0070.05711.95
4.3.110.0070.02311.95
4.3.100.0070.02011.95
4.3.90.0070.03011.95
4.3.80.0100.05011.95
4.3.70.0070.02011.95
4.3.60.0130.02711.95
4.3.50.0130.02711.95
4.3.40.0130.04011.95
4.3.30.0030.02711.95
4.3.20.0100.03311.95
4.3.10.0030.03011.95
4.3.00.0070.03311.95

preferences:
145.8 ms | 1394 KiB | 7 Q