how would you build an associative array from a string like the following:
$string = "foo=bar&x=y&kill=die&php=rocks&mycode=doesnt"
my first thoughts were to do the following:
$newt = explode( "&", $string );
//now $newt contains (foo=bar, x=y, ... )
foreach( $newt as $i )
{
list( $key, $string ) = explode("=", $i );
$final[] = array($key=>$string);
}
is this the wrong technique to build an associative array? i know that i can easily convert the string into a regular array, but associative arrays are just so much easier for others to read (and this is very important to my code.)
thanks to anyone who has the time to help.