Reputation: 513
I have a string like this:
$str = '"list":["test 1","test 2"]';
How to make an array:
$arr['list'] = array('test 1','test 2');
?
Upvotes: 0
Views: 108
Reputation: 786329
Make it a valid JSON string and use json_decode
function like this:
$str = '"list":["test 1","test 2"]';
$arr = json_decode('{' . $str . '}', true);
print_r($arr);
OUTPUT:
Array
(
[list] => Array
(
[0] => test 1
[1] => test 2
)
)
Upvotes: 3