PHP code example of faicchia / haversine
1. Go to this page and download the library: Download faicchia/haversine library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
faicchia / haversine example snippets
$distance = Haversine::kilometers(
from: Point::new(latitude: 41.902782, longitude: 12.496366), // Rome
to: Point::new(latitude: 51.509865, longitude: -0.118092) // London
);
// 1433.47926
$distance = Haversine::miles(
from: Point::new(latitude: 41.902782, longitude: 12.496366),
to: Point::new(latitude: 51.509865, longitude: -0.118092)
);
// 890.722441