I am having string str = “[123, 345, 567]”. I want to convert this to an array arr = [123, 345, 567]. How to do this?
Share
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.
If you know that the string contains an array, you can just plain use
eval;If you’re not sure, you can go for the a bit more involved removing braces, splitting on
,and collecting the numbers to an array;Demo of both here.