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); if(isset($values[$i]) && !in_array($values[$i], $array)) $array[] = $values[$i]; } } var_dump($array);
Output for git.master, git.master_jit, rfc.property-hooks
array(7) { [0]=> string(8) "Football" [1]=> string(6) "Hockey" [2]=> string(7) "Fechten" [3]=> string(7) "Germany" [4]=> string(7) "England" [5]=> string(13) "Meisterschaft" [6]=> string(11) "Weltmeister" }

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:
46.28 ms | 401 KiB | 8 Q