【发布时间】:2018-04-04 05:47:40
【问题描述】:
我无法访问我的 json,想知道错误在哪里。
$json = json_encode($data);
// string(1065) "[{"id":"test123","key":["one",...
然后我对其进行解码以使其可通过以下命令访问:
$json = json_decode($json, true);
// Output:
array(3) {
[0]=>
array(4) {
["id"]=>
string(14) "test123"
当我想回应它时,它给了我:
echo $json[0];
数组到字符串的转换
【问题讨论】:
-
print_r($json[0]);
-
$json[0]是一个数组。你不能echo一个数组。 -
echo $json[0]['id'];