Possible Duplicate:
Parse query string in JavaScript
I want to create an options array from a string. How can i create an array as
{
width : 100,
height : 200
}
from a string like
'width=100&height=200'
Is there to create such arrays?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s not an array, it’s an object. It’s not multidimensional either.
But anyway, you can split the string on the
&separator and then split each item on the=:Of course this doesn’t validate the input string, and doesn’t cater for when the same property appears more than once (you might like to create an array of values in that case), but it should get you started. It would be nice to encapsulate the above in a function, but that I leave as an exercise for the reader…