While doing some query string processing I stumbled upon this:
<?php
$in='a=6&b=7&8=c';
parse_str($in,$qs);
$out=array_merge($qs,array('9'=>'d'));
print_r($out);
?>
We get:
Array
(
[a] => 6
[b] => 7
[0] => c
[1] => d
)
Instead of:
Array
(
[a] => 6
[b] => 7
[8] => c
[9] => d
)
I understand why this is happening ('8' and '9' are being treated as numeric keys) but I'm not happy that I have to do this the long way round.
There must be a way to keep it simple. How do you slice, dice and cook your query strings?