3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
);<?php function distanceGeoPoints ($lat1, $lng1, $lat2, $lng2) { $earthRadius = 3958.75; $dLat = deg2rad($lat2-$lat1); $dLng = deg2rad($lng2-$lng1); $a = sin($dLat/2) * sin($dLat/2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($dLng/2) * sin($dLng/2); $c = 2 * atan2(sqrt($a), sqrt(1-$a)); $dist = $earthRadius * $c; // from miles $meterConversion = 1609; $geopointDistance = $dist * $meterConversion; // meters to km $geopointDistance = round($geopointDistance / 1000); return $geopointDistance; } // YOUR CODE HERE echo distanceGeoPoints(53.2168710816799, 6.5573533796185, 53.1402726806595, 6.5633787486733); ?>
based on qhXTD
Output for 4.3.0 - 7.1.0
);9