I may be doing it wrong but take a peek. If I hardcode the logic, it works but not if I try to use it as a variable.
if($range <= 50) {
$operator = "<=";
} else {
$operator = ">=";
}
foreach($cursor as $s) {
$data = round($this->distance($zip_lat, $zip_lon, $s["lat"],$s["lon"]), 2);
if ($data .$operator. $range) {
$zipcodes[] = "$s[zipcode]";
}
}
I mean, I could add the if/else inside the foreach but wasn’t sure if it adds any “overhead.”
try:
or use an eval()