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(); foreach($lines as $line) { $values = explode(' / ', $line); $depth = 0; foreach($values as $value) { if(!in_array($value, $array[$depth])) $array[$depth][] = $value; $depth++; } } var_dump($array);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 0 in /in/eseQK on line 27 Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /in/eseQK:27 Stack trace: #0 /in/eseQK(27): in_array('Football', NULL) #1 {main} thrown in /in/eseQK on line 27
Process exited with code 255.

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