3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseQueryString($str) { $result = []; foreach (explode('&', $str) as $element) { $parts = explode('=', $element, 2); $key = urldecode(array_shift($parts)); $value = $parts ? urldecode(array_shift($parts)) : ''; if (false !== $pos = strpos($key, '[')) { $base = substr($result, $key, 0, $pos++); $result[$base] = []; $target = &$result[$base]; do { $end = strpos($key, ']', $pos); $index = substr($key, $pos, $end - $pos); $target[$index] = []; $target = &$target[$index]; $pos = $end; } while($pos < strlen($key)); var_dump($result); } } } $str = 'foo=bar&baz[foo]=qux&baz[foo][goat]=chick'; parseQueryString($str);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: substr() expects at most 3 arguments, 4 given in /in/J5tul:13 Stack trace: #0 /in/J5tul(13): substr(Array, 'baz[foo]', 0, 3) #1 /in/J5tul(31): parseQueryString('foo=bar&baz[foo...') #2 {main} thrown in /in/J5tul on line 13
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:
39.99 ms | 401 KiB | 8 Q