php - How to explode URL parameter list string into paired [key] => [value] Array? -



php - How to explode URL parameter list string into paired [key] => [value] Array? -

possible duplicate: parse query string array

how can explode string such as:

a=1&b=2&c=3

so becomes:

array { [a] => 1 [b] => 2 [c] => 3 }

using regular explode() function delimited on & separate parameters not in [key] => [value] pairs.

thanks.

use php's parse_str function.

$str = 'a=1&b=2&c=3'; $exploded = array(); parse_str($str, $exploded); $exploded['a']; // 1

i wonder string from? if it's part of url after question mark (the query string of url), can access via superglobal $_get array:

# in script requested http://example.com/script.php?a=1&b=2&c=3 $_get['a']; // 1 var_dump($_get); // array(3) { ['a'] => string(1) '1', ['b'] => string(1) '2', ['c'] => string(1) '3' )

php url parameters explode

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -