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(' / ', $array); $depth = 0; foreach($values as $value) { $array[$depth][] = $value; $depth++; } } var_dump($array);
Output for 5.3.1 - 5.6.28, 7.0.0 - 7.1.0
Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 26 array(0) { }
Output for hhvm-3.10.0 - 3.12.0
Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 Warning: explode() expects parameter 2 to be string, array given in /in/uhLkP on line 23 Warning: Invalid argument supplied for foreach() in /in/uhLkP on line 29 array(0) { }
Output for 4.3.0 - 5.3.0
Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 Notice: Array to string conversion in /in/uhLkP on line 23 array(1) { [0]=> array(16) { [0]=> string(5) "Array" [1]=> string(5) "Array" [2]=> string(5) "Array" [3]=> string(5) "Array" [4]=> string(5) "Array" [5]=> string(5) "Array" [6]=> string(5) "Array" [7]=> string(5) "Array" [8]=> string(5) "Array" [9]=> string(5) "Array" [10]=> string(5) "Array" [11]=> string(5) "Array" [12]=> string(5) "Array" [13]=> string(5) "Array" [14]=> string(5) "Array" [15]=> string(5) "Array" } }