function subtract_and_square($n, $m)
{
return(pow($n - $m, 2));
}
function find_distance_between($p, $q)
{
$numargs = func_num_args();
if ($numargs != 2)
{
die("You must supply 2, and only 2, coordinates, no more, no less.\n");
}
else if (sizeof($p) != sizeof($q))
{
die("Coordinates do not have the same number of elements.\n");
}
else
{
$c = array_map("subtract_and_square", $p, $q);
return pow(array_sum($c), .5);
}
}
//test
$arr1 = array(4,3);
$arr2 = array(2,2);
echo find_distance_between($arr1,$arr2);