百度地图省市php获取

     $api = 'http://api.map.baidu.com/shangquan/forward/?qt=sub_area_list&ext=1&level=3&areacode=1&business_flag=0';
        $get_contents = file_get_contents($api);
        $json_map = json_decode($get_contents, true);
        $content = $json_map['content'];
        $sub = $content['sub'];
        $arr = [];
        foreach ($sub as $vals) {
            $arr[$vals['area_name']] = array_column($vals['sub'], 'area_name', 'area_code');
        }

        var_dump($arr);
posted @ 2019-07-26 09:04  尘梦  阅读(566)  评论(0编辑  收藏  举报