Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original Zip Code being used is skipped by getZipsInRange #5

Open
bigmike7801 opened this issue Apr 29, 2013 · 2 comments
Open

Original Zip Code being used is skipped by getZipsInRange #5

bigmike7801 opened this issue Apr 29, 2013 · 2 comments

Comments

@bigmike7801
Copy link

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.

@JayLevine
Copy link

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

@bigmike7801
Copy link
Author

I too am using that workaround, but just found it strange that the originating zip wasn't included in the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants