Search
 
SCRIPT & CODE EXAMPLE
 

PHP

find distance between two coordinate in php

function distance($lat1, $lon1, $lat2, $lon2, $unit) {

  $theta = $lon1 - $lon2;
  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.1515;
  $unit = strtoupper($unit);

  if ($unit == "K") {
      return round($miles * 1.609344);
  } else if ($unit == "N") {
      return round($miles * 0.8684);
  } else {
      return round($miles);
  }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php pakistan time zone 
Php :: get last slash value in php 
Php :: excerpt length wordpress 
Php :: laravel json response decode 
Php :: php escape special characters 
Php :: php change version linux 
Php :: laravel dropIndex 
Php :: laravel destroy session 
Php :: is php still used 
Php :: laravel add (s) at the end of text based on how many data 
Php :: ci3 upload file 
Php :: js var to php 
Php :: force https redirect php 
Php :: get the value of href in anchar tag php 
Php :: php string replace space 
Php :: laravel word count utf8 
Php :: header cross origin using php only for our domains and subdomain 
Php :: laravel create model with migration and controller 
Php :: laravel gigapay list employee 
Php :: get http host laravel 
Php :: php artian migrate table 
Php :: forward parameter from blade to another blade with filter 
Php :: php remove class attribute 
Php :: wp do sql query from function 
Php :: laravel get header from request 
Php :: get base url in magento 2 
Php :: laravel create table with model command line 
Php :: get http code curl php 
Php :: php preg_replace whitespace 
Php :: laravel blade @guest 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =