3v4l.org

run code in 300+ PHP versions simultaneously
<?php function grammar($description) { $g=array(); foreach(explode("\n",$description) as $line) { $sides = explode(" => ",$line); $lhs = $sides[0]; $lhs = $sides[1]; $alternatives = explode($rhs,' | '); $g[$lhs] = array(array_map("explode",$alternatives,array(" "))); } return $g; } $des =<<<G Exp => Term [+-] Exp | Term G; print_r(grammar($des));
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $rhs in /in/klWqN on line 10 Deprecated: explode(): Passing null to parameter #1 ($separator) of type string is deprecated in /in/klWqN on line 10 Fatal error: Uncaught ValueError: explode(): Argument #1 ($separator) cannot be empty in /in/klWqN:10 Stack trace: #0 /in/klWqN(10): explode('', ' | ') #1 /in/klWqN(18): grammar('Exp => Term [+-...') #2 {main} thrown in /in/klWqN on line 10
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:
38.5 ms | 401 KiB | 8 Q