range - How to know if a number belongs to a set in PHP? -


i'll give example, it's more straight point :

i'm working coordinates , want filter coordinates not belong set around picked coordinate. here latitude instance :

$latitude = 4.3999291; 

basically, have array of latitudes, $array_latitudes, , want test each 1 know if belong range around $latitude.

what i've done far :

$set = range($latitude-0.2, $latitude+0.2, 0.0000001); foreach ($array_latitudes $lat){     if (in_array($lat, $set)){         echo $lat;     } } 

so issue is, guessed it, performance... takes long time create array of values of 10^-7 range !

my question, then, : "is there simpler , more efficient way return latitudes in $array_latitudes belong set [$latitude-0.2, $latitude+0.2] precision of 10^-7 ?"

thanks :-)

could not test

if (abs($lat - $latitude) <= 0.2) {   echo $lat; } 

?


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -