0

I'm trying to split a string into an array where I can set the keyname instead of 1 2 3.

Here's the string:

"id=1&day=4&month=12&status=3"

The string can be just the ID, the ID and day, or all 4 together.

I want it to be like this:

array([id] => 1 [day] =>4...) 

1 Answer 1

4

Use parse_str():

parse_str("id=1&day=4&month=12&status=3", $parts);
var_export($parts);

Demo

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.