PHP code example of divineomega / php-distance
1. Go to this page and download the library: Download divineomega/php-distance 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/ */
divineomega / php-distance example snippets
$a = new Point($x1, $y1);
$b = new Point($x2, $y2);
$c = new Point($x3, $y3, $z3); # Infinite dimensions supported by some distance types
$distanceType = new Euclidean();
$distanceType = new EuclideanSquare();
$distanceType = new Haversine(); # For GPS coordinates (latitude and longitude)
$distance = (new Distance())
->type(new Euclidean()) # Type is optional, and defaults to Euclidean distance
->from($a)
->to($b)
->get();
composer