I have two variables which define a static longitude and latitude. I want to be able to define a multi dimensional array which holds the following: id, longitude and latitude.
What i want to achieve - from the static longitude to feed through the loop of arrays and if finds something within a radius of 50 miles (or whatever), it selects the potential ones and lists them.
I am not sure what formula or algorithm i can use to check the radius and bring back the nearest values.
Please note: not using databases in this example.
So far:
$mainLong = 57.7394571;
$mainLat = -4.386997;
$main = array(
array("loc_1",57.7394571,-4.686997),
array("loc_2",51.5286416,-0.1015987),
array("loc_3",51.2715146,-0.3953564),
array("loc_4",50.837418,-0.1061897)
);
foreach ( $main as $key => $value ) {
if($value[1] == $mainLong){
print_r($value);
}
}