Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Using case

  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Are you asking how to use the switch statement?
    Are you a Help Vampire?

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Sorry, I WAS referring to switch.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •