Get Linear Distance
This function will fetch the distance between two points. This is a linear distance and should not be used to get the distance between cities or latitude and longitude calculations. For these distance calculations you should use the http://www.phpro.org/examples/Get-Riemann-Distance.php.
<?php
/**
*
* @get the straight line distance between two points
*
* @param float $x1
*
* @param float $x2
*
* @param float $y1
*
* @param float $y2
*
* @return float
*
*/
function getLinearDistance($x1, $x2, $y1, $y2){
return (float) sqrt( pow($x1-$x2,2) + pow($y1-$y2, 2));
}
/*** example usage ***/
echo getLinearDistance(1, 8, 2, 5);
# 7.61577310586
?>