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(); $depth = 0; foreach($lines as $line) { $values = explode(' / ', $line); // find out how deep we have to go if(count($values) > $depth) { $depth = count($values); } } for($i = 0; $i < $depth; $i++) { // run through lines foreach($lines as $line) { $values = explode(' / ', $line); $array[] = $values[$depth]; } } var_dump($array);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 array(48) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL [31]=> NULL [32]=> NULL [33]=> NULL [34]=> NULL [35]=> NULL [36]=> NULL [37]=> NULL [38]=> NULL [39]=> NULL [40]=> NULL [41]=> NULL [42]=> NULL [43]=> NULL [44]=> NULL [45]=> NULL [46]=> NULL [47]=> NULL }
Output for hhvm-3.10.0 - 3.13.2
Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 Notice: Undefined index: 3 in /in/LrqI4 on line 35 array(48) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL [31]=> NULL [32]=> NULL [33]=> NULL [34]=> NULL [35]=> NULL [36]=> NULL [37]=> NULL [38]=> NULL [39]=> NULL [40]=> NULL [41]=> NULL [42]=> NULL [43]=> NULL [44]=> NULL [45]=> NULL [46]=> NULL [47]=> NULL }
Output for 4.3.0 - 5.2.17
Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 Notice: Undefined offset: 3 in /in/LrqI4 on line 35 array(48) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL [31]=> NULL [32]=> NULL [33]=> NULL [34]=> NULL [35]=> NULL [36]=> NULL [37]=> NULL [38]=> NULL [39]=> NULL [40]=> NULL [41]=> NULL [42]=> NULL [43]=> NULL [44]=> NULL [45]=> NULL [46]=> NULL [47]=> NULL }