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($array, $pid=0, $level=1) { $result=array(); foreach ($array as $key => $item) { if (($item['pid'] == $pid) && ($item['level'] == $level)) { $result[$key] = $item['title'] . '>>' . listItems($item['mid'], ($level+1)); } } return $result; } print_r(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.0150.00016.75
8.3.50.0040.01118.16
8.3.40.0180.00418.92
8.3.30.0030.01719.21
8.3.20.0070.00020.21
8.3.10.0070.00021.88
8.3.00.0060.00319.50
8.2.180.0100.01018.28
8.2.170.0140.00322.96
8.2.160.0100.00320.44
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00019.66
8.2.110.0090.00019.36
8.2.100.0090.00317.75
8.2.90.0040.00419.21
8.2.80.0080.00017.97
8.2.70.0040.00417.75
8.2.60.0040.00418.05
8.2.50.0040.00418.07
8.2.40.0000.00818.09
8.2.30.0040.00418.18
8.2.20.0000.00717.80
8.2.10.0030.00618.04
8.2.00.0040.00417.78
8.1.280.0000.01525.92
8.1.270.0040.00420.78
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0000.00922.06
8.1.230.0120.00017.76
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0000.01017.35
8.1.190.0080.00017.25
8.1.180.0050.00318.10
8.1.170.0080.00020.29
8.1.160.0040.00422.02
8.1.150.0070.00018.95
8.1.140.0050.00217.50
8.1.130.0030.00517.76
8.1.120.0030.00517.43
8.1.110.0040.00417.49
8.1.100.0000.00817.43
8.1.90.0000.00717.30
8.1.80.0020.00517.35
8.1.70.0050.00317.37
8.1.60.0030.00617.47
8.1.50.0030.00517.41
8.1.40.0030.00517.50
8.1.30.0080.00017.63
8.1.20.0000.00717.68
8.1.10.0040.00417.44
8.1.00.0000.00817.34
8.0.300.0000.00718.77
8.0.290.0050.00316.75
8.0.280.0000.00718.56
8.0.270.0040.00417.26
8.0.260.0030.00317.18
8.0.250.0070.00016.90
8.0.240.0000.00716.91
8.0.230.0040.00417.02
8.0.220.0070.00016.83
8.0.210.0040.00416.84
8.0.200.0030.00317.04
8.0.190.0000.00817.06
8.0.180.0030.00317.00
8.0.170.0040.00416.97
8.0.160.0030.00316.99
8.0.150.0000.00816.84
8.0.140.0040.00416.82
8.0.130.0000.00513.34
8.0.120.0050.00316.93
8.0.110.0040.00416.98
8.0.100.0040.00416.91
8.0.90.0070.00017.05
8.0.80.0120.00616.96
8.0.70.0060.00316.99
8.0.60.0000.00716.96
8.0.50.0040.00416.96
8.0.30.0110.00917.07
8.0.20.0140.00917.40
8.0.10.0000.00716.99
8.0.00.0090.00916.82
7.4.330.0000.00515.03
7.4.320.0000.00816.46
7.4.300.0070.00016.66
7.4.290.0070.00016.52
7.4.280.0000.00816.60
7.4.270.0030.00316.62
7.4.260.0040.00416.43
7.4.250.0000.00716.56
7.4.240.0020.00616.54
7.4.230.0030.00316.35
7.4.220.0090.00916.41
7.4.210.0160.00316.64
7.4.200.0000.00716.52
7.4.160.0070.00716.43
7.4.150.0100.00717.40
7.4.140.0080.01117.86
7.4.130.0070.01116.52
7.4.120.0090.01116.63
7.4.110.0090.00916.70
7.4.100.0160.00916.31
7.4.90.0070.01016.45
7.4.80.0100.00719.39
7.4.70.0130.00316.82
7.4.60.0100.00716.42
7.4.50.0020.00216.54
7.4.40.0100.00716.43
7.4.30.0030.01916.57
7.4.00.0100.00815.01
7.3.330.0060.00013.43
7.3.320.0050.01113.45
7.3.310.0070.00016.45
7.3.300.0000.00716.40
7.3.290.0050.00916.43
7.3.280.0100.00616.46
7.3.270.0140.00317.40
7.3.260.0120.01016.61
7.3.250.0130.00816.43
7.3.240.0160.00316.57
7.3.230.0080.00816.48
7.3.210.0090.00916.36
7.3.200.0070.01016.54
7.3.190.0060.00916.36
7.3.180.0060.01216.61
7.3.170.0130.00316.49
7.3.160.0070.01016.51
7.3.120.0070.01014.83
7.3.110.0090.00914.84
7.3.100.0040.00914.75
7.3.90.0050.00915.05
7.3.80.0070.00514.91
7.3.70.0030.00814.79
7.3.60.0110.00314.79
7.3.50.0020.01214.95
7.3.40.0020.01014.82
7.3.30.0080.00514.91
7.3.20.0090.00516.63
7.3.10.0090.00616.64
7.3.00.0080.00916.63
7.2.330.0090.00916.48
7.2.320.0130.00416.89
7.2.310.0090.01216.67
7.2.300.0120.00916.60
7.2.290.0070.01716.80
7.2.250.0050.01415.21
7.2.240.0070.01114.91
7.2.230.0050.01215.25
7.2.220.0050.00815.09
7.2.210.0050.00715.04
7.2.200.0060.00915.07
7.2.190.0080.00314.96
7.2.180.0060.00814.94
7.2.170.0030.00815.15
7.2.130.0030.01017.04
7.2.120.0060.01017.04
7.2.110.0190.00016.94
7.2.100.0070.00716.91
7.2.90.0090.00617.04
7.2.80.0090.00616.78
7.2.70.0030.01316.97
7.2.60.0110.00516.72
7.2.50.0060.00617.07
7.2.40.0060.00917.08
7.2.30.0070.01016.57
7.2.20.0140.00417.17
7.2.10.0070.00716.99
7.2.00.0080.00618.26
7.1.330.0050.01115.78
7.1.320.0080.00415.52
7.1.310.0080.00515.84
7.1.300.0050.00915.73
7.1.290.0030.01015.72
7.1.280.0030.00915.81
7.1.270.0060.00515.83
7.1.260.0050.00715.97
7.1.250.0030.00715.54
7.1.240.0140.00415.75
7.1.230.0070.01015.75
7.1.220.0060.00615.82
7.1.210.0120.00315.57
7.1.200.0040.00715.68
7.1.190.0040.01115.82
7.1.180.0080.00815.81
7.1.170.0050.00515.75
7.1.160.0080.00415.68
7.1.150.0040.00816.01
7.1.140.0120.00315.69
7.1.130.0120.00315.70
7.1.120.0100.00315.92
7.1.110.0070.00716.07
7.1.100.0100.00516.91
7.1.90.0070.01016.01
7.1.80.0100.01015.69
7.1.70.0050.00516.43
7.1.60.0080.01017.64
7.1.50.0080.01316.06
7.1.40.0140.00315.79
7.1.30.0060.00615.74
7.1.20.0080.00315.61
7.1.10.0100.00715.84
7.1.00.0080.03818.89
7.0.330.0110.00815.03
7.0.320.0100.00315.44
7.0.310.0080.00315.37
7.0.300.0120.00315.36
7.0.290.0070.00415.11
7.0.280.0100.00615.42
7.0.270.0070.01015.38
7.0.260.0060.01315.32
7.0.250.0070.00715.10
7.0.240.0060.00915.28
7.0.230.0060.00615.46
7.0.220.0030.00615.33
7.0.210.0070.00715.22
7.0.200.0020.00915.88
7.0.190.0080.00415.47
7.0.180.0110.00015.43
7.0.170.0030.01315.39
7.0.160.0000.01315.42
7.0.150.0030.01015.13
7.0.140.0090.03718.66
7.0.130.0070.00415.42
7.0.120.0080.03218.78
7.0.110.0080.04018.64
7.0.100.0080.03018.69
7.0.90.0050.04218.69
7.0.80.0060.03518.86
7.0.70.0030.04118.73
7.0.60.0110.03718.74
7.0.50.0090.03418.85
7.0.40.0030.04117.79
7.0.30.0070.03717.75
7.0.20.0040.04117.80
7.0.10.0070.03417.75
7.0.00.0050.03417.73
5.6.380.0030.00914.48
5.6.370.0050.00514.37
5.6.360.0060.00614.35
5.6.350.0030.01014.59
5.6.340.0090.00614.57
5.6.330.0070.00714.49
5.6.320.0040.01113.84
5.6.310.0030.01014.43
5.6.300.0030.01014.32
5.6.290.0090.00414.66
5.6.280.0020.04217.58
5.6.270.0030.00714.49
5.6.260.0000.04617.78
5.6.250.0090.03717.88
5.6.240.0030.04317.77
5.6.230.0050.04217.74
5.6.220.0020.04517.61
5.6.210.0000.04317.53
5.6.200.0070.04217.62
5.6.190.0020.04417.71
5.6.180.0030.04217.73
5.6.170.0040.04117.61
5.6.160.0070.03217.70
5.6.150.0080.03717.65
5.6.140.0050.04117.65
5.6.130.0050.04017.77
5.6.120.0030.04317.73
5.6.110.0030.04117.72
5.6.100.0020.03817.58
5.6.90.0090.03517.70
5.6.80.0050.04017.30
5.6.70.0080.03617.44
5.6.60.0060.03617.40
5.6.50.0040.03717.21
5.6.40.0020.04117.39
5.6.30.0030.04017.13
5.6.20.0060.03817.27
5.6.10.0070.03517.21
5.6.00.0080.02917.18
5.5.380.0050.03514.30
5.5.370.0020.03814.63
5.5.360.0070.03714.39
5.5.350.0050.03014.47
5.5.340.0050.03814.78
5.5.330.0020.04014.71
5.5.320.0030.03714.65
5.5.310.0030.04014.63
5.5.300.0060.03614.55
5.5.290.0050.03714.57
5.5.280.0050.04014.49
5.5.270.0050.04014.68
5.5.260.0040.04014.80
5.5.250.0040.03814.52
5.5.240.0000.03614.27
5.5.230.0030.04014.29
5.5.220.0020.03714.23
5.5.210.0080.03314.08
5.5.200.0040.03514.41
5.5.190.0020.03914.17
5.5.180.0050.03914.29
5.5.170.0030.00611.14
5.5.160.0040.03514.34
5.5.150.0030.03514.20
5.5.140.0070.02814.11
5.5.130.0060.03014.29
5.5.120.0020.03914.36
5.5.110.0080.03214.39
5.5.100.0040.03514.42
5.5.90.0010.03614.19
5.5.80.0050.03514.16
5.5.70.0060.03513.97
5.5.60.0000.03914.26
5.5.50.0030.03614.35
5.5.40.0000.03714.25
5.5.30.0020.03814.28
5.5.20.0000.03814.27
5.5.10.0030.03814.31
5.5.00.0030.03714.26
5.4.450.0060.03815.19
5.4.440.0020.04015.25
5.4.430.0060.03515.44
5.4.420.0060.03615.24
5.4.410.0050.03515.08
5.4.400.0030.03814.86
5.4.390.0060.03715.12
5.4.380.0030.03615.13
5.4.370.0090.03215.05
5.4.360.0040.03915.07
5.4.350.0000.03315.18
5.4.340.0070.03215.21
5.4.330.0000.00911.04
5.4.320.0060.03015.04
5.4.310.0020.03715.21
5.4.300.0050.03415.11
5.4.290.0040.03615.10
5.4.280.0000.03914.98
5.4.270.0080.03215.15
5.4.260.0030.03715.11
5.4.250.0020.04115.08
5.4.240.0020.03815.22
5.4.230.0040.03215.07
5.4.220.0050.03615.33
5.4.210.0020.03515.08
5.4.200.0050.03515.01
5.4.190.0060.03115.09
5.4.180.0050.03415.17
5.4.170.0080.03314.84
5.4.160.0060.03515.15
5.4.150.0030.04015.13
5.4.140.0050.03013.71
5.4.130.0020.03513.81
5.4.120.0080.03213.89
5.4.110.0000.04113.92
5.4.100.0050.03713.69
5.4.90.0050.03313.80
5.4.80.0020.03713.85
5.4.70.0050.03413.80
5.4.60.0020.03813.80
5.4.50.0050.02813.63
5.4.40.0010.03413.81
5.4.30.0050.03313.76
5.4.20.0020.03613.71
5.4.10.0020.04013.70
5.4.00.0070.03313.43
5.3.290.0070.02712.53
5.3.280.0000.03812.72
5.3.270.0030.03512.60
5.3.260.0020.03712.65
5.3.250.0040.03612.70
5.3.240.0050.03512.63
5.3.230.0020.03612.59
5.3.220.0020.03812.52
5.3.210.0050.03712.54
5.3.200.0020.03212.64
5.3.190.0080.03012.65
5.3.180.0050.03512.61
5.3.170.0020.03712.59
5.3.160.0050.03212.64
5.3.150.0040.03612.65
5.3.140.0000.04012.62
5.3.130.0050.03712.62
5.3.120.0030.03712.67
5.3.110.0020.03812.72
5.3.100.0030.03712.49
5.3.90.0070.03312.47
5.3.80.0050.03512.45
5.3.70.0050.02812.49
5.3.60.0050.03412.34
5.3.50.0040.03412.43
5.3.40.0030.03312.46
5.3.30.0040.03512.45
5.3.20.0070.03112.41
5.3.10.0020.03412.26
5.3.00.0080.03012.25
5.2.170.0060.02612.25
5.2.160.0020.03012.25
5.2.150.0020.03312.25
5.2.140.0030.03012.25
5.2.130.0030.02812.25
5.2.120.0030.03012.25
5.2.110.0030.03012.25
5.2.100.0030.03012.25
5.2.90.0040.02612.25
5.2.80.0060.02812.25
5.2.70.0040.03112.25
5.2.60.0030.03012.25
5.2.50.0030.03112.25
5.2.40.0020.03012.25
5.2.30.0030.02812.25
5.2.20.0000.03112.25
5.2.10.0020.02912.25
5.2.00.0070.02712.25
5.1.60.0040.02412.25
5.1.50.0000.02812.25
5.1.40.0030.02612.25
5.1.30.0030.02712.25
5.1.20.0000.02512.25
5.1.10.0020.02712.25
5.1.00.0010.02612.25
5.0.50.0000.02212.25
5.0.40.0020.02212.25
5.0.30.0020.02812.25
5.0.20.0000.02212.25
5.0.10.0030.01812.25
5.0.00.0020.03212.25
4.4.90.0000.01712.25
4.4.80.0030.01812.25
4.4.70.0000.02012.25
4.4.60.0000.01712.25
4.4.50.0020.01712.25
4.4.40.0010.02712.25
4.4.30.0060.01212.25
4.4.20.0000.01912.25
4.4.10.0000.01912.25
4.4.00.0000.02712.25
4.3.110.0020.01512.25
4.3.100.0020.01512.25
4.3.90.0000.01712.25
4.3.80.0010.02512.25
4.3.70.0070.01212.25
4.3.60.0030.01512.25
4.3.50.0000.01812.25
4.3.40.0000.02412.25
4.3.30.0000.01812.25
4.3.20.0020.01612.25
4.3.10.0020.01712.25
4.3.00.0020.01412.25

preferences:
56.28 ms | 400 KiB | 5 Q