Jump to content

[SOLVED] ZIP/ Postal Code Look-up feature


AndrewJ1313

Recommended Posts

I would like to at a ZIP/ Postal Code look-up to a site. There are basically 22 zones covering the U.S and Canada and I would like to direct users to certain information depending on what ZIP code they enter. In most cases, entire states are in one zone.

 

My question is, is there a way to write an IF statement that would cover a number range?

 

An example would be I want all ZIP codes ranging from 40000 through 49999 to be directed to zone 1. Can I write this without saying:

 

IF $zip = "40000" || $zip = "40001 || $zip = "40002" ... 

 

Please let me know if this makes sense or if I need to clarify what I'm doing.

 

Thanks for all responses,

Andrew

 

Link to comment
https://forums.phpfreaks.com/topic/141938-solved-zip-postal-code-look-up-feature/
Share on other sites

if($zip >= 40000 && $zip <= 49999)

 

 

You know, the minute I posted this, I started to think I was over thinking the whole thing:) Thanks this will help.

 

And just in case anyone knows a better way to build a ZIP code look-up feature, I'm all ears...or eyes in the case of blogging.

 

Many thanks for the help.

 

Andrew

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.