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 :: schema key issue laravel 
Php :: wordpress function _() not working 
Php :: run specific seeder laravel 
Php :: import csv to laravel 
Php :: why php $_session in not working in react js 
Php :: wordpress add sitemap.xml to robots.txt dynamically 
Php :: how to get php code from website 
Php :: laravel rename file if exists 
Php :: avoid data insertion if an error occurs in laravel 
Php :: How to download file with laravel 
Php :: laravel carbon subtract minutes to current time 
Php :: php artisan reset --force 
Php :: Laravel hasmany withSum() 
Php :: How to get ID and other string in url 
Php :: How to list notification from database 
Php :: Only Show Specific Countries In Caldera Forms Phone Field 
Php :: install php56-php-ldap on ubuntu 20.04 
Php :: database interaction in codeigniter 
Php :: WooCommerce Catalog Mode snippets 
Php :: convert code python to php 
Php :: 12 months service expiary in php 
Php :: curl_setopt timeout php 
Php :: wp ajax error handling 
Php :: MethodNotAllowedHttpException 
Php :: rollback a specific migration laravel 
Php :: install php 7.4 fpm 
Php :: laravel 8 app with more than one database 
Php :: comment_info 
Php :: Laravel Read multiple file extensions 
Php :: check input value is not empty or spaced php 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =