I’ll give an example, it’s will be more straight to the point :
I’m working with coordinates and I want to filter the coordinates that do not belong to a set around the picked coordinate. Here for the latitude for instance :
$latitude = 4.3999291;
Basically, I have an array of latitudes, $array_latitudes, and I want to test each one to know if they belong to a range around $latitude.
What I’ve done so far :
$set = range($latitude-0.2, $latitude+0.2, 0.0000001);
foreach ($array_latitudes as $lat){
if (in_array($lat, $set)){
echo $lat;
}
}
So the issue is, you guessed it, about the performance… It takes a really long time to create an array of values of a 10^-7 range !
My question, then, is : “Is there a simpler and more efficient way to return the latitudes in $array_latitudes which belong to the set [$latitude-0.2, $latitude+0.2] with a precision of 10^-7 ?”
Thanks all 🙂
Could you not just test
?