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) - 1; } } for($i = 0; $i < $depth; $i++) { // run through lines foreach($lines as $line) { $values = explode(' / ', $line); if(isset($values[$i]) && !in_array($values[i], $array)) $array[] = $values[$i]; } } var_dump($array);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 array(32) { [0]=> string(8) "Football" [1]=> string(8) "Football" [2]=> string(8) "Football" [3]=> string(8) "Football" [4]=> string(8) "Football" [5]=> string(8) "Football" [6]=> string(8) "Football" [7]=> string(8) "Football" [8]=> string(8) "Football" [9]=> string(8) "Football" [10]=> string(6) "Hockey" [11]=> string(6) "Hockey" [12]=> string(6) "Hockey" [13]=> string(7) "Fechten" [14]=> string(7) "Fechten" [15]=> string(7) "Fechten" [16]=> string(7) "Germany" [17]=> string(7) "Germany" [18]=> string(7) "Germany" [19]=> string(7) "Germany" [20]=> string(7) "Germany" [21]=> string(7) "England" [22]=> string(7) "England" [23]=> string(7) "England" [24]=> string(7) "England" [25]=> string(7) "England" [26]=> string(7) "Germany" [27]=> string(7) "Germany" [28]=> string(7) "Germany" [29]=> string(13) "Meisterschaft" [30]=> string(13) "Meisterschaft" [31]=> string(11) "Weltmeister" }
Output for hhvm-3.10.0 - 3.13.2
Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 array(32) { [0]=> string(8) "Football" [1]=> string(8) "Football" [2]=> string(8) "Football" [3]=> string(8) "Football" [4]=> string(8) "Football" [5]=> string(8) "Football" [6]=> string(8) "Football" [7]=> string(8) "Football" [8]=> string(8) "Football" [9]=> string(8) "Football" [10]=> string(6) "Hockey" [11]=> string(6) "Hockey" [12]=> string(6) "Hockey" [13]=> string(7) "Fechten" [14]=> string(7) "Fechten" [15]=> string(7) "Fechten" [16]=> string(7) "Germany" [17]=> string(7) "Germany" [18]=> string(7) "Germany" [19]=> string(7) "Germany" [20]=> string(7) "Germany" [21]=> string(7) "England" [22]=> string(7) "England" [23]=> string(7) "England" [24]=> string(7) "England" [25]=> string(7) "England" [26]=> string(7) "Germany" [27]=> string(7) "Germany" [28]=> string(7) "Germany" [29]=> string(13) "Meisterschaft" [30]=> string(13) "Meisterschaft" [31]=> string(11) "Weltmeister" }
Output for 4.3.0 - 5.2.17
Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 Notice: Use of undefined constant i - assumed 'i' in /in/IqYYh on line 35 Notice: Undefined index: i in /in/IqYYh on line 35 array(32) { [0]=> string(8) "Football" [1]=> string(8) "Football" [2]=> string(8) "Football" [3]=> string(8) "Football" [4]=> string(8) "Football" [5]=> string(8) "Football" [6]=> string(8) "Football" [7]=> string(8) "Football" [8]=> string(8) "Football" [9]=> string(8) "Football" [10]=> string(6) "Hockey" [11]=> string(6) "Hockey" [12]=> string(6) "Hockey" [13]=> string(7) "Fechten" [14]=> string(7) "Fechten" [15]=> string(7) "Fechten" [16]=> string(7) "Germany" [17]=> string(7) "Germany" [18]=> string(7) "Germany" [19]=> string(7) "Germany" [20]=> string(7) "Germany" [21]=> string(7) "England" [22]=> string(7) "England" [23]=> string(7) "England" [24]=> string(7) "England" [25]=> string(7) "England" [26]=> string(7) "Germany" [27]=> string(7) "Germany" [28]=> string(7) "Germany" [29]=> string(13) "Meisterschaft" [30]=> string(13) "Meisterschaft" [31]=> string(11) "Weltmeister" }