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 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
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"}]}" }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
78.61 ms | 407 KiB | 5 Q