3v4l.org

run code in 300+ PHP versions simultaneously
<?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); $array[] = $values[$depth]; } } var_dump($array);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 2 in /in/JocrI on line 35 Warning: Undefined array key 2 in /in/JocrI on line 35 Warning: Undefined array key 2 in /in/JocrI on line 35 Warning: Undefined array key 2 in /in/JocrI on line 35 Warning: Undefined array key 2 in /in/JocrI on line 35 Warning: Undefined array key 2 in /in/JocrI on line 35 array(32) { [0]=> string(6) "1.Liga" [1]=> string(6) "1.Liga" [2]=> string(6) "2.Liga" [3]=> string(6) "2.Liga" [4]=> string(6) "2.Liga" [5]=> string(6) "1.Liga" [6]=> string(6) "1.Liga" [7]=> string(6) "2.Liga" [8]=> string(6) "2.Liga" [9]=> string(6) "3.Liga" [10]=> string(6) "1.Liga" [11]=> string(6) "1.Liga" [12]=> string(6) "2.Liga" [13]=> NULL [14]=> NULL [15]=> NULL [16]=> string(6) "1.Liga" [17]=> string(6) "1.Liga" [18]=> string(6) "2.Liga" [19]=> string(6) "2.Liga" [20]=> string(6) "2.Liga" [21]=> string(6) "1.Liga" [22]=> string(6) "1.Liga" [23]=> string(6) "2.Liga" [24]=> string(6) "2.Liga" [25]=> string(6) "3.Liga" [26]=> string(6) "1.Liga" [27]=> string(6) "1.Liga" [28]=> string(6) "2.Liga" [29]=> NULL [30]=> NULL [31]=> NULL }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.04 ms | 403 KiB | 8 Q