How to convert JavaScript statement to PHP array
I read have one string like this:
$var = '[["tom",10,17.5],["af",13,["x",10,"y",12,"z",11]]]';
How should I convert this string to a PHP 开发者_如何学Carray?
That looks like JSON. Use json_decode
.
<?php
$json = "[["tom",10,17.5],["af",13,["x",10,"y",12,"z",11]]]";
$obj = json_decode($json);
print $obj->{'tom'};
?>
精彩评论