我得到了以下代码,无论如何都要像数组那样使用它?
$var =
"{"uid":"cb463625fc9dde2d82207e15bde1b674513094011b2976.06073807","name":"marius"}{"uid":"2393d7a6a3258894acc34581978453fa513094011b2ab8.28630478","name":"buenyamin"}";
将其打印出来,如
echo $var[0].uid."<br>";
echo $var[1].uid;
答案 0 :(得分:1)
试试这个:
$array = json_decode($var,true);
echo "<pre>";
print_r($array);
注意:需要json_decode中的第二个参数true
才能将输出作为数组输出,否则输出将是对象
答案 1 :(得分:1)
使用json_decode将字符串解码为PHP数组。
$var =
"{"uid":"cb463625fc9dde2d82207e15bde1b674513094011b2976.06073807","name":"marius"}{"uid":"2393d7a6a3258894acc34581978453fa513094011b2ab8.28630478","name":"buenyamin"}";
echo '<pre>' . print_r(json_code($var, true)) . '</pre>';