Arrays past to functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

 I am learning about passing arrays to functions, and am trying to
create a function that will display a total amount for a price for
several states.  Say using CA, WA, and OR, and setting there tax rates
at, whatever, say 5%, 7%, and 8% respectively.  I want a function I can
pass the array of states, and tax rates to that will display the total
amount (amount + tax) of say a $1500 purchase.  I am trying to use a
switch statement to accomplish this, but I think I may be in over my
head trying to do this with what I have learned so far...  Here is the
code I have so far I get 0 every time I run it, try not to laugh... :-)
Thanks guys.

 

 

$State = array ("CA" , "WA" , "OR");

   function compute_salestax ($Amount , $State)

            {

             switch ($State)

                    {

                     case "CA" :

                          $Rate = "1.05";

                          break;

                     case "WA" :

                          $Rate = "1.07";

                          break;

                     case "OR" :

                          $Rate = "1.08";

                          break;

                    }

                    

             global $Rate;

             $Truetax = ($Amount * $Rate);

             echo "$Truetax <br />";

            }

   $Amount = 1500;

   compute_salestax($Amount , $State);

 

 

 

Jacob Bergman

Network Technician

Pullman School District #267

(509) 432-4012

jbergman@xxxxxxxxxxxxxxxxx

 


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux