Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to calcuate distance between 2 place with the help of zip code in Php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 103
    Comment on it

    Hello Everyone, today I am here to guide you "How to calcuate distance between 2 place with the help of zip code in Php".

    $point and $point are two places, you can pass these values into total_distance() function
    $radius is earth radius in miles
    $distance return the calculated distance between 2 points.
    

    The below code helps you to find the distance between 2 place.

    function total_distance($point1, $point2)
    {
        $radius      = 3958;      // radius
        $deg_per_radius = 57.29578;  // degrees
    
        $distance = ($radius * pi() * sqrt(
                    ($point1['lat'] - $point2['lat'])
                    * ($point1['lat'] - $point2['lat'])
                    + cos($point1['lat'] / $deg_per_rad)  
                    * cos($point2['lat'] / $deg_per_rad)  
                    * ($point1['long'] - $point2['long'])
                    * ($point1['long'] - $point2['long'])
            ) / 180);
    
        return $distance;  // Returned using the units used for $radius.
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: