Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse a querystring formatted string? [duplicate]

I have a string category=45&format=1 that I want to convert into a key=value array.

Does anyone know if there is a quick way of doing this without having to write a function that explode's the & and then the =?

like image 276
fire Avatar asked Mar 08 '26 12:03

fire


1 Answers

Since you're dealing with the URL query format: parse_str

parse_str('category=45&format=1', $array);

http://php.net/parse_str

like image 153
deceze Avatar answered Mar 10 '26 01:03

deceze