I've been doing this in MySQL for years, but how can I do this in PHP?
Example CoordinateArray: http://pastebin.com/grVsbgL9
I'd like to return all the coordinates within 100 miles of a given coordinate.
function getCoordinatesWithinRadius ($coordinateArray, $center, $radius) {
//
return $resultArray;
}
In MySQL I typically used a query like:
SELECT *, ( 3959 * acos( cos( radians($latitude) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($longitude) ) + sin( radians($latitude) ) * sin( radians( latitude ) ) ) ) AS distance FROM table HAVING distance < $radius ORDER BY distance;
How can I do the same in PHP?