如何将JavaScript语句转换为PHP数组

时间:2011-09-20 05:51:06

标签: php javascript

我读过这样的字符串:

$var = '[["tom",10,17.5],["af",13,["x",10,"y",12,"z",11]]]';

我应该如何将此字符串转换为PHP数组?

2 个答案:

答案 0 :(得分:0)

看起来像JSON。使用json_decode

答案 1 :(得分:-1)

<?php

$json = "[["tom",10,17.5],["af",13,["x",10,"y",12,"z",11]]]";

$obj = json_decode($json);
print $obj->{'tom'}; 
?>