If you have absolute coordinates, you don't need MapID. You're also using a bunch of unneeded trig functions.
PHP Code:
function getDistance($x1,$y1,$z1,$x2,$y2,$z2,$speed)
return sqrt(pow($x1-$x2,2)+pow($y1-$y2,2)+pow($z1-$z2,2))/$speed;
end
Note: $speed needs to be in the same units as the coordinates, this means since the absolute coordinates of a map are measured in yards, $speed needs to match it too. For 100% speed, this would be a value of 7.