高德地图php 换取经纬度 地址

/**
 * 根据地址 获取经纬度
 * @param $address
 * @return mixed
 */
function addresstolatlag($address){

    $url='http://restapi.amap.com/v3/geocode/geo?address='.$address.'&key=80051202ff5b334bd3c94e18d20a';
    if($result=file_get_contents($url))
    {
        $result = json_decode($result,true);
        //判断是否成功
        if(!empty($result['count'])){
            return  explode(',',$result['geocodes']['0']['location']);
        }else{
            return false;
        }
    }
}
 

/**
 * 根据经纬度 获取地址
 * @param $address23.2322,12.15544
 * @return mixed
 */
function getaddress($address){

    $url="http://restapi.amap.com/v3/geocode/regeo?output=json&location=".$address."&key=80051202ff5b33334bd3c94e18d20a";
    if($result=file_get_contents($url))
    {
        $result = json_decode($result,true);
        if(!empty($result['status'])&&$result['status']==1){
            return $result['regeocode']['formatted_address'];
        }else{
            return false;
        }

    }
}