該json數(shù)據(jù)為:Array ( [content] => stdClass Object ( [location] => stdClass Object ( [lat] => 29.726563 [lng] => 120.248396 ) [locid] => d8fc4a4572356bd53f9c041b8e6f5ffc [radius] => 30 [confidence] => 1 ) [result] => stdClass Object ( [error] => 161 [loc_time] => 2016-10-18 10:49:07 ) ) 我想提取lng和lat的值,請(qǐng)教php源碼,順便給下逐行顯示數(shù)組每個(gè)數(shù)值的源碼,謝謝
1 回答

紅顏莎娜
TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超13個(gè)贊
你這個(gè)json轉(zhuǎn)過來還是對(duì)象,直接轉(zhuǎn)成數(shù)組就好取值了。
$arr = json_decode($str,1); // $str 代表json字符串
轉(zhuǎn)成數(shù)組就可以隨便取值了。
$lat = $arr['content']['location']['lat'];
$ing= $arr['content']['location']['ing'];
- 1 回答
- 0 關(guān)注
- 2007 瀏覽
添加回答
舉報(bào)
0/150
提交
取消