3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $strings = "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"; $lines = explode("\n", $strings); $array = array(); foreach($lines as $line) { $values = explode(' / ', $line); $depth = 0; foreach($values as $value) { if(!in_array($array[$depth]) $array[$depth][] = $value; $depth++; } } var_dump($array);
Output for 5.4.0 - 5.4.5
Parse error: syntax error, unexpected '$array' (T_VARIABLE) in /in/AhRMS on line 27
Process exited with code 255.
Output for 5.3.0 - 5.3.15
Parse error: syntax error, unexpected T_VARIABLE in /in/AhRMS on line 27
Process exited with code 255.