原本json數(shù)據(jù):{"status":0,"result":{"location":{"lng":116.32298703399,"lat":39.983424051248},"formatted_address":"北京市海淀區(qū)中關(guān)村大街27號(hào)1101-08室","business":"中關(guān)村,人民大學(xué),蘇州街","addressComponent":{"city":"北京市","district":"海淀區(qū)","province":"北京市","street":"中關(guān)村大街","street_number":"27號(hào)1101-08室"},"cityCode":131}}經(jīng)過json_decode處理后:array(2) {["status"]=>int(0)["result"]=>array(5) {["location"]=>array(2) {["lng"]=>float(116.32298703399)["lat"]=>float(39.983424051248)}["formatted_address"]=>string(48) "北京市海淀區(qū)中關(guān)村大街27號(hào)1101-08室"["business"]=>string(32) "中關(guān)村,人民大學(xué),蘇州街"["addressComponent"]=>array(5) {["city"]=>string(9) "北京市"["district"]=>string(9) "海淀區(qū)"["province"]=>string(9) "北京市"["street"]=>string(15) "中關(guān)村大街"["street_number"]=>string(15) "27號(hào)1101-08室"}["cityCode"]=>int(131)}}怎樣拿到["formatted_address"]的值
3 回答

元芳怎么了
TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊
json_decode函數(shù)返回值可以直按照數(shù)組的方式取,比如:
$res = '....' ; // $res是一個(gè)json字符串。 $newres = json_decode( $res ); // 解析json字符串 // json_decode有兩個(gè)參數(shù),第二個(gè)參數(shù)寫成 true 表示返回的數(shù)據(jù)為數(shù)組。 |
添加回答
舉報(bào)
0/150
提交
取消