3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseQuoteAware(string $commandLine) : array{ $args = []; preg_match_all('/"((?:\\\\.|[^\\\\"])*)"|[~^][^\s~^]*|\S+\s*/u', $commandLine, $matches, PREG_UNMATCHED_AS_NULL); $size = count($matches[0]); for ($k = 0; $k < $size; ++$k) { if ($matches[1][$k] !== null) { $args[] = str_replace('\"', '"', $matches[1][$k]); continue; } $match = $matches[0][$k]; $level = (substr_count($match, "[") - substr_count($match, "]")) + (substr_count($match, "{") - substr_count($match, "}")) + (substr_count($match, "(") - substr_count($match, ")")); if ($level == 0 || $k == $size - 1) { $args[] = rtrim($match); } else { $matches[0][$k + 1] = $match . $matches[0][$k + 1]; } } return $args; } $cmdLine = '/tellraw @a[name="Arie1906", c=1] "quoted \"你好\"" {"rawtext": [{"text":"§bI am blue"}]}'; var_dump(parseQuoteAware($cmdLine));
Output for git.master_jit, git.master
array(4) { [0]=> string(8) "/tellraw" [1]=> string(24) "@a[name="Arie1906", c=1]" [2]=> string(15) "quoted "你好"" [3]=> string(42) "{"rawtext": [{"text":"§bI am 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:
16.46 ms | 405 KiB | 5 Q