GEO helper
Simple class that helps you to work with coordinates.
Install
composer require zkelo/geo-helperUsage
use zkelo\helpers\Geo;
$pointA = [47.208734, 38.936660];
$pointB = [47.222097, 39.720340];
$distance = Geo::distance($pointA[0], $pointA[1], $pointB[0], $pointB[1]);
echo $distance; // 59208.551919281By default helper uses Vincenty formula to calculate distance, but you can change it to Haversine formula by passing correspond constant to last parameter.
// ...
$distance = Geo::distance($pointA[0], $pointA[1], $pointB[0], $pointB[1], Geo::DISTANCE_FORMULA_HAVERSINE);
echo $distance; // 59189.903668868Reference
All code of this repo taken from this Stack Overflow answer.