Re: Arrays past to functions

From: Date: Fri, 27 Jul 2007 18:49:54 +0000
Subject: Re: Arrays past to functions
References: 1 2 3  Groups: php.windows php.windows php.windows 
Request: Send a blank email to php-windows+get-28272@lists.php.net to get a copy of this message
Niel Archer wrote:
Hi Jacob. Spotted another problem. function compute_salestax ($Amount , $State) {
    $taxRate = array("CA" => 5 , "WA" =>  7, "OR" => 8);
    return $Amount / 100  * $taxRate($State);
} $payment = 1500; $locale = 'CA'; print "Tax on $amount in $locale is " . compute_salestax ($payment , $locale); -- Niel Archer
hi Niel, I believe Jacob wanted to know how he could calculate the tax for _all_ states passed in as an array in one go. Yours simply gives it for 1 State ("locale"). Other than thatm $taxRate($state) translates to Array($state) which gives an E_FATAL_ERROR obviously. I assume you meant to say $taxRate[$State].

« previous php.windows (#28272) next »