我一直在尝试使用以下格式从 json 中提取数据:
[{"_type":"pipe","time":"2013-10-25 02:42:51","1_price":["00.00"],"1_name":["name"],"_template":"675fgy","1_purl":["http://"],"_cached_page_id":"te487","1_image":["image.jpeg"],"url":"http://"},
[{"_type":"pipe","time":"2013-10-25 02:42:55","1_price":["00.00"],"1_name":["name"],"_template":"16778f","1_purl":["http://"],"_cached_page_id":"456gt","1_image":["image.jpeg"],"url":"http://"},
我的以下代码返回“Array2013-10-25 02:42:51”即。它只返回“时间”的值似乎无法获得值“1_name”
请告诉我我做错了什么
$url = "http://.../api.output";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
$arr = json_decode($result, true);
foreach($arr as $val)
{
echo $val['1_name'];
echo $val['time'];
}