php根据两点经纬度算距离
/**
* 计算根据两点间经纬度计算两点间距离
* @param unknown $lat1
* @param unknown $lng1
* @param unknown $lat2
* @param unknown $lng2
* @return number /Km
*/
function getDistance($lat1=0, $lon1=0, $lat2=0, $lon2=0){
//将角度转为狐度
$radLat1=deg2rad($lat1);//deg2rad()函数将角度转换为弧度
$radLat2=deg2rad($lat2);
$radLng1=deg2rad($lon1);
$radLng2=deg2rad($lon2);
$a=$radLat1-$radLat2;
$b=$radLng1-$radLng2;
$s=2*asin(sqrt(pow(sin($a/2),2)+cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)))*6378.137;
return $s;
}