: This article mainly describes how to calculate the distance between two groups of experience levels. For more information about PHP tutorials, see.
/*** Calculate the distance between the two sets of economic parameters. * params: lat1 degree 1, lng1 Level 1, lat2 degree 2, lng2 level 2, len_type (1: m | 2: km); * Echo GetDistance ($ lat1, $ lng1, $ lat2, $ lng2 ). 'MI'; */function GetDistance ($ lat1, $ lng1, $ lat2, $ lng2, $ len_type = 1, $ decimal = 2) {$ EARTH_RADIUS = 6378.137; // the semi-complete earth. the pseudo-Earth is the rule body $ PI = 3.1415926; // The week ratio $ radLat1 = $ lat1 * $ PI/180.0; $ radLat2 = $ lat2 * $ PI/180.0; $ a = $ radLat1-$ radLat2; $ B = ($ lng1 * $ PI/180.0) -($ lng2 * $ PI/180.0); $ s = 2 * asin (sqrt (pow (sin ($ a/2), 2) + cos ($ radLat1) * cos ($ radLat2) * pow (sin ($ B/2), 2); $ s = $ s * $ EARTH_RADIUS; $ s = round ($ s * 1000); if ($ len_type> 1) {$ s/= 1000;} return round ($ s, $ decimal );}
The preceding section describes how to calculate the distance between the two groups of experience indicators, including some content, and hope to help those who are interested in PHP tutorials.