Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-09-2009, 02:01 PM   PM User | #1
zenix
New Coder

 
Join Date: Jun 2009
Posts: 63
Thanks: 10
Thanked 0 Times in 0 Posts
zenix is an unknown quantity at this point
Using case

Hello,
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.

Code:
<?php
//Zip code
$zone =$_POST['zip'];
//zone 2 zips
$zone2 = array( '070', '071', '072','073','074','075','076','078','079','100','101','102','103','196');
$zone3=array('004','005','010','011','012','013','014','015','016','017','447',);
$zone4=array('025','026','040','041','042','043','619',');
then I plan to test for the zone chosen by this:
Code:
 if(in_array($zone,$Zone2))
{ 
// 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.
zenix is offline   Reply With Quote
Old 10-09-2009, 02:32 PM   PM User | #2
tomws
Senior Coder

 
tomws's Avatar
 
Join Date: Nov 2007
Location: Arkansas
Posts: 2,644
Thanks: 29
Thanked 330 Times in 326 Posts
tomws will become famous soon enoughtomws will become famous soon enough
Are you asking how to use the switch statement?
__________________
Are you a Help Vampire?
tomws is offline   Reply With Quote
Old 10-09-2009, 02:45 PM   PM User | #3
zenix
New Coder

 
Join Date: Jun 2009
Posts: 63
Thanks: 10
Thanked 0 Times in 0 Posts
zenix is an unknown quantity at this point
Sorry, I WAS referring to switch.
zenix is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:10 PM.


Advertisement
Log in to turn off these ads.