View Full Version : Using case

10-09-2009, 03:01 PM
I have been learning php over the past year and have decided to put my knowledge to the test by volunteering to build a web site for a church. They need to be able to calculate shipping costs by zone. I have entered all the zip prefixes into 8 arrays, 1 array for each zone. A LOT of typing.

Anyway, I was thinking maybe I could use a case layout to determine which zone is being queried. The problem is, I have no clue where to start. Here is a small amount of what I have.

//Zip code
$zone =$_POST['zip'];
//zone 2 zips
$zone2 = array( '070', '071', '072','073','074','075','076','078','079','100','101','102','103','196');

then I plan to test for the zone chosen by this:

// They are in Zone 2

And then having the prices for shipping associated with the zone be displayed for the customer.

If someone could point me in the right direction I would really appreciate it.

10-09-2009, 03:32 PM
Are you asking how to use the switch statement (http://php.net/manual/en/control-structures.switch.php)?

10-09-2009, 03:45 PM
Sorry, I WAS referring to switch.