Original Zip Code being used is skipped by getZipsInRange
Let's say for example I create a new instance of Zipcode and then loop through those results by doing:
$zip = new Zipcode("98674");
foreach ($zip->getZipsInRange(0, 15) as $k => $v) { $zip_codes[] = sprintf($v); //print_r($v); }
The original zip code being searched of 98674 isn't returned with the results.
Hello,
I don't remember why I started doing this... if it was in a doc or comment I read, or if I just noticed it...
I always add the zip I'm searching on to the array before I start.
Here the array $zipList is initialized with only 1 value, the search zip... then a foreach to add all the nearby zips
$zipStuff = new ZipCode($data['zip'], $dbh);
$zipList = array($data['zip']); // start with the array only containing the search zip! foreach ($zipStuff->getZipsInRange(0, $data['distanceMenu']) as $miles=>$zip) { $zipList[] = $zip;
$zipDistance[$zip->getZip()] = round($miles + 0, 1);
}
Jay
I too am using that workaround, but just found it strange that the originating zip wasn't included in the results.