### php

#### How to find distance between two set of co-ordinates in php [closed]

```Let suppose i have two set of co-ordinates, i got these co-ordinates from map source through android application and sent it to server, now server side will calculate distance between them and print.
```
```Try This
<?php
\$points = array
(
"point1" => "0,55" ,
"point2" => "0,52"
);
function get_distance(\$inputs)
{
\$count = 1;
foreach(\$inputs as \$x => \$y)
{
echo \$x." = (".\$y.")<br>";
\$p[\$count] = explode(",",\$y);
\$count++;
}
\$x1 = \$p;
\$y1 = \$p;
\$x2 = \$p;
\$y2 = \$p;
\$distance = sqrt(pow((\$x2 - \$x1) , 2) + pow((\$y2 - \$y1) , 2));
echo \$distance;
}
get_distance(\$points);
?>
```
```Try this:
function calculateDistance(\$lat1, \$lon1, \$lat2, \$lon2, \$unit) {
\$theta = \$lon1 - \$lon2;
\$dist = acos(\$dist);
\$miles = \$dist * 60 * 1.1515;
\$unit = strtoupper(\$unit);
if (\$unit == "K") {
return (\$miles * 1.609344);
} else if (\$unit == "N") {
return (\$miles * 0.8684);
} else {
return \$miles;
}
}
and you can call it like:
calculateDistance(\$latitude1, \$longitude1, \$latitude2, \$longitude2, "K");
Reference```

### Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization