2

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 =?

0

2 Answers 2

10

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

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

http://php.net/parse_str

Sign up to request clarification or add additional context in comments.

Comments

4

If it's a query string or doesn't contain special characters you can use parse_str.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.