从坐标PHP函数计算距离

I'm using MySQLi with mysqlnd driver, and using a function to get long/lat coordinates and calculate the distance between them, however I'm having issues with strange numbers and errors regarding "expected double, string given".

In my database, the long/lat values are stored as "Decimal (18,15)". I then use a MySQLi query to retireve this from the database, and store them in a PHP Variable like so:

$latitudeTo = $postcoderow[latitude];
$float_latitudeTo = floatval($latitudeTo);
$longitudeTo = $postcoderow[longitude];
$float_longitudeTo = floatval($longitudeTo);

The other set of long/lat are the same (just using different names).

However, the postcodes will be only from the UK, and using the following PHP Function

function calculateDistance($float_latitudeFrom, $float_longitudeFrom, $float_latitudeTo, $float_longitudeTo, $earthMeanRadius = 3440) {
$deltaLatitude = deg2rad($float_latitudeTo - $float_latitudeFrom);
$deltaLongitude = deg2rad($float_longitudeTo - $float_longitudeFrom);
$a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
     cos(deg2rad($float_latitudeFrom)) * cos(deg2rad(float_latitudeTo)) *
     sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
return $earthMeanRadius * $c;
}

//Function call with the coordinates.
$miles = calculateDistance($float_latitudeFrom, $float_longitudeFrom, $float_latitudeTo, $float_longitudeTo, $earthMeanRadius = 3440);

I'm getting values of 3000+ miles returned (I just echo '.$miles.')

How do I store $float_latitudeTo... etc as doubles, as they are decimals from the database, however are converted to a string which is causing errors. I think the PHP Function itself is fine, just how I'm parsing the values.

Thanks for your time!