开发者

How to convert JavaScript statement to PHP array

开发者 https://www.devze.com 2023-04-05 20:53 出处:网络
I read have one string like this: $var = \'[[\"tom\",10,17.5],[\"af\",13,[\"x\",10,\"y\",12,\"z\",11]]]\';

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'}; 
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消