What I am trying to do is I have entries in the database which have a lat/long stored with them. I want to calculate the distance between users lat/long and entries lat/long
Use distance-matrix google api to calculate distance between latitude and longitude.
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,
'https://maps.googleapis.com/maps/api/distancematrix/json?origins='.$prev_add.'&destinations='.$curr_add.'&key=keyyouhavetogenerate'
);
$content = curl_exec($ch);
$array = json_decode($content);
$obj = json_decode($content, TRUE);
$distance = $obj['rows'][0]['elements'][0]['distance']['text'];
to use this api you will need key,to know more about how to generate key visit https://developers.google.com/maps/documentation/distance-matrix/intro