The examples in this article describe how people and their distances are implemented in a PHP query. Share to everyone for your reference, specific as follows:
<?php//Get 4 dots around the point $distance = 1;//range (unit kilometer) $lat = 113.873643;
$LNG = 22.573969; Define (' Earth_radius ', 6371);//Earth radius, average radius of 6371km $DLNG = 2 * ASIN (SIN ($distance/(2 * earth_radius))/cos (Deg2rad ($lat)))
;
$DLNG = Rad2deg ($DLNG);
$dlat = $distance/earth_radius;
$dlat = Rad2deg ($dlat); $squares = Array (' Left-top ' =>array (' lat ' => $lat + $dlat, ' LNG ' => $lng-$dlng), ' Right-top ' =>array (' lat ' =&G
t; $lat + $dlat, ' LNG ' => $lng + $dlng), ' Left-bottom ' =>array (' lat ' => $lat-$dlat, ' LNG ' => $lng-$DLNG),
' Right-bottom ' =>array (' lat ' => $lat-$dlat, ' LNG ' => $LNG + $dlng));
Print_r ($squares [' left-top '] [' lat ']); Records matching from a number of libraries $info _sql = "select * from ' A ' where lat<>0 and lat>{$squares [' Right-bottom '] [' lat ']} and lat<{$s
quares[' left-top ' [' Lat ']} and lng>{$squares [' left-top '] [' LNG ']} and lng<{$squares [' Right-bottom '] [' LNG ']} '; Gets the distance between two points function getdistancebetweenpointsnew ($latitude 1, $longitude 1, $latitude 2, $longitude 2){$theta = $longitude 1-$longitude 2; $miles = (sin (Deg2rad ($latitude 1)) * Sin (Deg2rad ($latitude 2)) + (cos (Deg2rad ($latitude 1)) * cos (Deg2rad ($latitude 2)) *
Cos (Deg2rad ($theta)));
$miles = ACOs ($miles);
$miles = Rad2deg ($miles);
$miles = $miles * 60 * 1.1515;
$feet = $miles * 5280;
$yards = $feet/3;
$kilometers = $miles * 1.609344;
$meters = $kilometers * 1000;
Return compact (' Miles ', ' feet ', ' yards ', ' kilometers ', ' meters ');
$point 1 = Array (' lat ' => 40.770623, ' Long ' =>-73.964367);
$point 2 = Array (' lat ' => 40.758224, ' Long ' =>-73.917404);
$distance = getdistancebetweenpointsnew ($point 1[' lat '), $point 1[' long ', $point 2[' lat '], $point 2[' long ']); foreach ($distance as $unit => $value) {echo $unit. ': ' Number_format ($value, 4). '
<br/> ';
}?>
For more information on PHP related content readers can view the site topics: "PHP Mathematical Operation Skills Summary", "PHP Array" operation Skills Encyclopedia, "PHP Regular Expression Usage Summary", "Php+ajax Tips and Application Summary", "PHP operation and operator Usage Summary", " PHP Network Programming Skills Summary, "Introduction to PHP Basic Grammar", "PHP date and Time usage summary", "PHP object-oriented Programming Introductory Course", "PHP string (String) Usage Summary", "Php+mysql database Operation Tutorial" and " A summary of common PHP database operations tips
I hope this article will help you with the PHP program design.