https://github.com/yrehan32/php-haversine
A package used to calculate the distance between two coordinate points using the haversine algorithm
https://github.com/yrehan32/php-haversine
algorithm haversine haversine-formula php php-library
Last synced: 3 days ago
JSON representation
A package used to calculate the distance between two coordinate points using the haversine algorithm
- Host: GitHub
- URL: https://github.com/yrehan32/php-haversine
- Owner: yrehan32
- License: lgpl-2.1
- Created: 2022-12-27T14:29:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-27T15:36:05.000Z (about 3 years ago)
- Last Synced: 2025-08-25T10:57:06.189Z (5 months ago)
- Topics: algorithm, haversine, haversine-formula, php, php-library
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Installation
Install the library via Composer
```bash
composer require yrehan32/php-haversine
```
After installing the library, you can use it in your code like this:
```php
use Yrehan32\PhpHaversine\Haversine;
/*
* Calculate the distance between two points
* @param float $latitudeFrom Latitude of the first point
* @param float $longitudeFrom Longitude of the first point
* @param float $latitudeTo Latitude of the second point
* @param float $longitudeTo Longitude of the second point
* @param string $separators Number of digits after the comma (default: 2)
*
* @return float Distance between the two points
*/
$distance = Haversine::calculate(
52.2296756,
21.0122287,
52.406374,
16.9251681
);
echo $distance; // It will print 278.46
```
## License
This library is licensed under the LGPL-2.1 License.