1

I have a string a[b][c] and I need to convert it into multidimensional PHP array. Does anybody knows a quick solution for that without using eval()?

3
  • 1
    Please show us your string in full and explain what you've already tried... Commented Apr 29, 2014 at 11:03
  • I literally have a string form[auth][key]. I need this parsed into array("form"=>array("auth"=>array("key"))) Commented Apr 29, 2014 at 11:09
  • If it's valid PHP why don't you want to eval() it? If you want to pass data in string format why don't you serialize it? Commented Apr 29, 2014 at 11:18

1 Answer 1

2

Ok, I found solution for that:

parse_str("a[b][c]", $result);

Resulted multidimensional array is written into $result variable.

Source

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.