We can easily calculate distance between two addresses using Google Maps API and PHP . We have created a simple PHP function for getting distance between two addresses. getDistance() function grouped all functionalities together and it accepts three parameters. $addressFrom – Required. Pass the from address. $addressTo – Required. Pass the to address. $unit – Optional. Pass the first letter of desire unit. Default is Mile. ( K – kilometre, N – Nautical Mile) getDistance() function is given below. /** * * Author: CodexWorld * Function Name: getDistance() * $addressFrom => From address. * $addressTo => To address. * $unit => Unit type. * **/ function getDistance($addressFrom, $addressTo, $unit){ //Change address format $formattedAddrFrom = str_replace(' ','+',$addressFrom); $formattedAddrTo = str_replace(' ','+',$addressTo); //Send request and receive json data $geocodeFrom = file_get_contents('http://maps.googl...