views:

16

answers:

1

I have point A(x,y) and B(x,y). they listed as array (a => array(x,y), b => array(x,y))

How get lenght between point A and B. Please help in php. :)

+2  A: 

Well, remember your high-school geometry.

r = square_root((x2 - x1)^2 + (y2 - y1)^2)

So in php:

$dx = $points['b'][0] - $points['a'][0];
$dy = $points['b'][1] - $points['a'][1];
$r = sqrt(pow($dx, 2) + pow($dy, 2));
ircmaxell