3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseQuoteAware(string $commandLine) : array{ $args = []; preg_match_all('/"((?:\\\\.|[^\\\\"])*)"|(\S+)/u', $commandLine, $matches); foreach($matches[0] as $k => $_){ for($i = 1; $i <= 2; ++$i){ if($matches[$i][$k] !== ""){ $match = $matches[$i][$k]; $args[] = preg_replace('/\\\\([\\\\"])/u', '$1', $match) ?? throw new AssumptionFailedError(preg_last_error_msg()); break; } } } return $args; } $cmdLine = '/tellraw @a[name="Arie1906", c=1] "quoted \"string\"" {"rawtext": [{"text":"§bI am blue"}]}'; var_dump(parseQuoteAware($cmdLine));
Output for git.master_jit, git.master
array(8) { [0]=> string(8) "/tellraw" [1]=> string(19) "@a[name="Arie1906"," [2]=> string(4) "c=1]" [3]=> string(15) "quoted "string"" [4]=> string(11) "{"rawtext":" [5]=> string(14) "[{"text":"§bI" [6]=> string(2) "am" [7]=> string(8) "blue"}]}" }

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:
55.82 ms | 406 KiB | 5 Q