Re: Arrays past to functions
| From: | Abhisek Dutta | Date: | Tue, 31 Jul 2007 09:37:06 +0000 |
| Subject: | Re: Arrays past to functions | ||
| References: | 1 2 3 4 5 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-28288@lists.php.net to get a copy of this message | ||
Here's what i made:
<?
$taxrate=array('CA'=>5,'WA'=>7,'OR'=>8);
$states=array('CA','WA','OR');
function calctax($amount, $st)
{
global $taxrate;
global $states;
$tax=$amount*$taxrate[$st];
return $tax/100;
}
$amnt=200;
foreach($states as $st)
{
print "Tax in $st for amount $amnt is ".calctax($amnt, $st);
print "<br/>\n";
}
?>
Output:
Tax in CA for amount 200 is 10
Tax in WA for amount 200 is 14
Tax in OR for amount 200 is 16/
/