3v4l.org

run code in 200+ 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(); function flatten($arr) { global $result; foreach($arr as $r) { if(isset($r["r"])) { $x = $r["r"]; unset($r["r"]); $result[] = $r; flatten($x); } else { $result[] = $r; } } } $tmp = array(); foreach($menu as &$m) { $id = $m[0]; $ref = $m[1]; $m["r"] = array_filter($menu, function($item) use ($id) { return $item[1] == $id; }); if(sizeof($m["r"]) == 0) unset($m["r"]); if($ref == 0) { $tmp[] = $m; } } flatten($tmp); $target = array( array(3,0,'Tiger 1', 1, 10), array(1,3,'Wurm 1.1', 2, 10), array(7,1,'Baer 1.1.1', 3, 0), array(5,3,'Katze 1.2', 2, 11), array(8,3,'Schwein 1.3', 2, 12), array(6,0,'Pferd 2', 1, 20), array(2,6,'Vogel 2.1', 2, 30), array(4,6,'Hund 2.2', 2, 40), array(9,4,'Esel 2.2.1', 3, 0), ); var_dump($result == $target);
based on PTuRc

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)
7.4.00.0070.01114.80
7.2.60.0090.00316.73
7.2.00.0060.00919.34
7.1.200.0000.01515.70
7.1.100.0060.00918.28
7.1.70.0000.00716.93
7.1.60.0060.01619.59
7.1.50.0060.01616.98
7.1.00.0100.06722.43
7.0.200.0100.00616.69
7.0.60.0030.06019.79
7.0.50.0030.05717.89
7.0.40.0030.04320.25
7.0.30.0630.06320.16
7.0.20.0300.08020.33
7.0.10.0170.08020.18
7.0.00.0070.06720.07
5.6.280.0030.06321.16
5.6.210.0130.07320.68
5.6.200.0030.08318.20
5.6.190.0030.05020.41
5.6.180.3730.05320.64
5.6.170.0200.08320.62
5.6.160.0200.07320.55
5.6.150.0100.08018.28
5.6.140.0030.05718.16
5.6.130.0100.08018.13
5.6.120.0030.05021.11
5.6.110.0070.05021.03
5.6.100.0070.09021.17
5.6.90.0070.06021.01
5.6.80.0130.06020.51
5.6.70.0230.07320.51
5.5.350.0270.08020.43
5.5.340.0070.08318.08
5.5.330.0130.08020.13
5.5.320.0230.04020.34
5.5.310.0170.04020.27
5.5.300.0070.03718.01
5.5.290.0070.08017.98
5.5.280.0030.04020.99
5.5.270.0070.08320.99
5.5.260.0130.07720.86
5.5.250.0170.08020.73
5.5.240.0400.06720.28
5.4.450.0630.06019.55
5.4.440.1200.05019.60
5.4.430.0700.05719.33
5.4.420.0900.05719.47
5.4.410.0930.05719.50
5.4.400.0900.06719.15
5.4.390.0770.05019.01
5.4.380.0930.05019.38
5.4.370.0930.05019.14
5.4.360.0630.06018.98
5.4.350.0770.06019.38
5.4.340.0770.05319.22
5.4.320.1100.04319.27
5.4.310.0970.06318.98
5.4.300.0930.06019.05
5.4.290.0870.05719.11
5.4.280.1070.04319.01
5.4.270.0900.05319.14
5.4.260.0730.06319.14
5.4.250.0870.06319.14
5.4.240.0770.05718.99
5.4.230.0800.05019.12
5.4.220.0970.05019.25
5.4.210.0800.05019.28
5.4.200.0730.05316.95
5.4.190.0870.06719.01
5.4.180.0830.04719.25
5.4.170.0830.05719.17
5.4.160.0730.05319.03
5.4.150.0970.04319.24
5.4.140.1070.03716.59
5.4.130.0970.04316.59
5.4.120.0900.05316.58
5.4.110.0700.05016.36
5.4.100.1130.05716.52
5.4.90.0970.05016.54
5.4.80.0800.04016.35
5.4.70.0900.05316.33
5.4.60.0930.04716.30
5.4.50.0970.05716.41
5.4.40.1030.04716.38
5.4.30.1030.04316.39
5.4.20.0900.05016.41
5.4.10.0700.05316.54
5.4.00.0830.05716.01
5.3.290.0800.06014.76
5.3.280.0900.03714.49
5.3.270.0770.05714.55
5.3.260.0800.05314.66
5.3.250.0800.04714.65
5.3.240.0800.04714.66
5.3.230.0700.05714.54
5.3.220.0730.06714.57
5.3.210.1100.06014.75
5.3.200.0900.04714.62
5.3.190.1200.04014.54
5.3.180.1070.04314.65
5.3.170.0730.05314.51
5.3.160.0700.05714.74
5.3.150.0930.07014.61
5.3.140.0770.05714.74
5.3.130.0800.05314.64
5.3.120.0770.05714.50
5.3.110.0900.06014.84
5.3.100.0970.05013.93
5.3.90.0970.05013.96
5.3.80.0970.04713.96
5.3.70.0830.06014.10
5.3.60.1130.05313.95
5.3.50.0900.05714.00
5.3.40.0930.04713.90
5.3.30.0930.05013.81
5.3.20.0970.04013.63
5.3.10.0930.04013.70
5.3.00.0930.06713.76
5.2.170.0630.04311.07
5.2.160.0570.05011.21
5.2.150.0600.04311.31
5.2.140.0600.04311.07
5.2.130.0600.04711.05
5.2.120.0600.04311.03
5.2.110.0830.04711.02
5.2.100.0870.03311.34
5.2.90.0700.04311.02
5.2.80.0930.04310.97
5.2.70.0830.05711.16
5.2.60.0770.05011.15
5.2.50.0770.04310.94
5.2.40.0630.04011.02
5.2.30.0670.04310.89
5.2.20.0430.05010.83
5.2.10.0470.04010.78
5.2.00.0470.04010.88
5.1.60.0500.03010.00
5.1.50.0500.03310.02
5.1.40.0600.03310.23
5.1.30.0630.03010.25
5.1.20.0570.04010.38
5.1.10.0500.04710.06
5.1.00.0470.03710.02
5.0.50.0300.0238.80
5.0.40.0200.0308.27
5.0.30.0300.0378.26
5.0.20.0200.0308.29
5.0.10.0270.0308.19
5.0.00.0330.0538.16
4.4.90.0270.0205.88
4.4.80.0270.0205.89
4.4.70.0270.0205.84
4.4.60.0200.0275.87
4.4.50.0200.0235.78
4.4.40.0270.0305.77
4.4.30.0270.0205.79
4.4.20.0300.0275.88
4.4.10.0400.0235.84
4.4.00.0330.0305.90
4.3.110.0300.0275.78
4.3.100.0230.0235.80
4.3.90.0300.0275.68
4.3.80.0270.0375.77
4.3.70.0300.0175.77
4.3.60.0270.0235.76
4.3.50.0330.0175.80
4.3.40.0330.0275.71
4.3.30.0130.0234.52
4.3.20.0100.0274.43
4.3.10.0200.0174.43
4.3.00.0170.0207.30