3v4l.org

run code in 200+ php & hhvm versions
<?php $string = "Football / Germany / 1.Liga Football / Germany / 1.Liga Football / Germany / 2.Liga Football / Germany / 2.Liga Football / Germany / 2.Liga Football / England / 1.Liga Football / England / 1.Liga Football / England / 2.Liga Football / England / 2.Liga Football / England / 3.Liga Hockey / Germany / 1.Liga Hockey / Germany / 1.Liga Hockey / Germany / 2.Liga Fechten / Meisterschaft Fechten / Meisterschaft Fechten / Weltmeister"; class ArrayStacker { public function stackArray($string) { $array = $this->splitString($string); $stackedArray = array(); foreach($array as $row) { $stackedArray[] = $this->_stack($row); } return $stackedArray; } /** * Split the whole string into a big array * * @param string $string * @return array */ protected function splitString($string) { $lines = explode("\n", $string); $i = 0; $array = array(); foreach($lines as $line) { $values = explode(' / ', $line); foreach($values as $v => $value) { $values[$v] = trim($value); // make sure we got no whitespaces } $array[$i] = $values; $i++; } return $array; } protected function _stack($array) { $stackedArray = array(); $key = array_shift($array); if(count($array) == 1) { $stackedArray[$key] = $array[0]; // that's a single value } else { $stackedArray[$key] = $this->_stack($array); } return $stackedArray; } } $arrayStacker = new ArrayStacker(); var_dump($arrayStacker->stackArray($string));

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.1.100.0040.01118.25
7.1.70.0000.00817.13
7.1.60.0150.01119.30
7.1.50.0040.01816.99
7.1.00.0000.08022.32
7.0.200.0040.00416.59
7.0.140.0000.07722.13
7.0.120.0030.04022.26
7.0.60.0030.08319.93
7.0.50.0030.08717.95
7.0.40.0130.03320.27
7.0.30.0400.05720.09
7.0.20.0270.08020.22
7.0.10.0270.07020.10
7.0.00.0170.06020.27
5.6.280.0130.06721.14
5.6.210.0030.05020.76
5.6.200.0170.07318.18
5.6.190.0170.08020.52
5.6.180.0370.06020.48
5.6.170.0200.07020.45
5.6.160.0070.05320.51
5.6.150.0030.04018.19
5.6.140.0000.04318.19
5.6.130.0130.04718.15
5.6.120.0100.08021.03
5.6.110.0000.06021.01
5.6.100.0130.06320.96
5.6.90.0070.08021.05
5.6.80.0170.06320.51
5.6.70.0230.06020.41
5.5.350.0230.05320.50
5.5.340.0100.07318.07
5.5.330.0030.08320.27
5.5.320.0270.04020.48
5.5.310.0270.06320.50
5.5.300.0030.08718.02
5.5.290.0100.07717.98
5.5.280.0070.04320.89
5.5.270.0030.04320.84
5.5.260.0130.04720.77
5.5.250.0170.07320.70
5.5.240.0070.08020.30
5.4.450.0030.04319.59
5.4.440.0100.04719.56
5.4.430.0170.07319.56
5.4.420.0070.06719.30
5.4.410.0070.06319.27
5.4.400.0100.07719.25
5.4.390.0000.04319.12
5.4.380.0030.08019.08
5.4.370.0070.08019.22
5.4.360.0170.06319.16
5.4.350.0030.08019.25
5.4.340.0070.06019.14
5.4.320.0070.06318.85
5.4.310.0100.03319.24
5.4.300.0100.07318.98
5.4.290.0070.04018.84
5.4.280.0030.07319.15
5.4.270.0130.04318.98
5.4.260.0070.05318.95
5.4.250.0130.05319.14
5.4.240.0100.07719.23
5.4.230.0100.07318.85
5.4.220.0030.05319.13
5.4.210.0070.04019.20
5.4.200.0070.06019.00
5.4.190.0030.04318.99
5.4.180.0030.06318.84
5.4.170.0100.03319.14
5.4.160.0100.05318.85
5.4.150.0130.07019.22
5.4.140.0000.05016.44
5.4.130.0030.03716.35
5.4.120.0030.07716.37
5.4.110.0070.04016.30
5.4.100.0100.06316.30
5.4.90.0170.02716.30
5.4.80.0030.07316.28
5.4.70.0100.05316.54
5.4.60.0170.06316.28
5.4.50.0100.06716.37
5.4.40.0070.07016.38
5.4.30.0030.04016.37
5.4.20.0070.07316.36
5.4.10.0170.03716.46
5.4.00.0070.07015.91
5.3.290.0100.08014.70
5.3.280.0070.08014.63
5.3.270.0000.04314.64
5.3.260.0100.06314.68
5.3.250.0070.06714.66
5.3.240.0070.04014.63
5.3.230.0130.05314.78
5.3.220.0070.06714.55
5.3.210.0030.07714.62
5.3.200.0070.07714.75
5.3.190.0100.07014.61
5.3.180.0070.05714.66
5.3.170.0030.07714.60
5.3.160.0030.08314.60
5.3.150.0170.06714.64
5.3.140.0070.07314.61
5.3.130.0130.07714.64
5.3.120.0070.07714.57
5.3.110.0170.07014.57
5.3.100.0100.03014.11
5.3.90.0000.06714.19
5.3.80.0030.06713.98
5.3.70.0030.06314.12
5.3.60.0030.04714.08
5.3.50.0030.07314.13
5.3.40.0070.06013.99
5.3.30.0030.03714.00
5.3.20.0000.05313.73
5.3.10.0070.04013.82
5.3.00.0130.06313.66
5.2.170.0100.05711.21
5.2.160.0070.03311.07
5.2.150.0070.03311.23
5.2.140.0000.04011.14
5.2.130.0070.03011.16
5.2.120.0070.03311.13
5.2.110.0030.03011.14
5.2.100.0070.03711.18
5.2.90.0070.03311.28
5.2.80.0070.06311.12
5.2.70.0000.05311.27
5.2.60.0130.03311.07
5.2.50.0030.05010.96
5.2.40.0030.06311.07
5.2.30.0000.04710.96
5.2.20.0030.04010.97
5.2.10.0030.03010.79
5.2.00.0070.03010.64
5.1.60.0000.03010.09
5.1.50.0070.03710.02
5.1.40.0000.03010.15
5.1.30.0000.05010.38
5.1.20.0070.05710.39
5.1.10.0070.03310.09
5.1.00.0030.03010.10
5.0.50.0130.0208.64
5.0.40.0070.0408.51
5.0.30.0030.0378.32
5.0.20.0070.0408.20
5.0.10.0030.0208.18
5.0.00.0070.0308.24
4.4.90.0000.0178.07
4.4.80.0030.0378.07
4.4.70.0000.0178.07
4.4.60.0000.0208.07
4.4.50.0000.0178.07
4.4.40.0030.0408.07
4.4.30.0030.0178.07
4.4.20.0030.0308.07
4.4.10.0030.0208.07
4.4.00.0030.0378.07
4.3.110.0000.0238.07
4.3.100.0030.0178.07
4.3.90.0070.0108.07
4.3.80.0000.0278.07
4.3.70.0000.0178.07
4.3.60.0070.0178.07
4.3.50.0070.0378.07
4.3.40.0070.0208.07
4.3.30.0030.0378.07
4.3.20.0000.0178.07
4.3.10.0030.0238.07
4.3.00.0000.0378.07