Create two arrays of numbers and add the values in each array, to each
corresponding value by index number in the other array ?
Is their a function that can do this?
Varuna
--
Varuna Seneviratna
No 514 Udumulla Road
Battaramulla
Sri Lanka
Tel : 011-2888620
Mobile:0715617141
Wat is the problem with this code.
- Original Message
From: Abhisek Dutta <[EMAIL PROTECTED]>
To: php-windows@lists.php.net
Sent: Tuesday, 31 July, 2007 3:07:06 PM
Subject: Re: [PHP-WIN] Arrays past to functions
Here's what i made:
5,'WA'=>7,'OR'
Here's what i made:
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 "\n";
}
?>
Tax = 120.00 in OR.
I hope this helps!!
Jeff White
-Original Message-
From: Jacob Bergman [mailto:[EMAIL PROTECTED]
Sent: Friday, July 27, 2007 2:07 PM
To: php-windows@lists.php.net
Subject: RE: [PHP-WIN] Arrays past to functions
Thanks a bunch guys, I'm out for the day, I wi
Niel Archer wrote:
Hi
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 must say, you're the first (and only) person I've ever seen using
> foreach(): endforeach in PHP. As far as I know, most people use
> curly-bracers (in this case), I'm sure most people wouldn't even know
> this was possible (I had to look it up in the manual, and it's only in a
> single not
Hi
> 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 y
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_salesta
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
2007 11:03 AM
To: php-windows@lists.php.net
Subject: Re: [PHP-WIN] Arrays past to functions
Hi Jacob
Sorry, my fault entirely. I wrote it in a hurry after copy/pasting your
example. I didn't change the variable names properly or test it.
I still haven't been able to test, but this sho
Hi Jacob
Sorry, my fault entirely. I wrote it in a hurry after copy/pasting your
example. I didn't change the variable names properly or test it.
I still haven't been able to test, but this should work better now.
function compute_salestax ($Amount , $State)
{
$taxRate = array("CA" => 5 , "W
-
Thanks for the help guys!
Jacob Bergman
Network Technician
Pullman School District #267
(509) 432-4012
[EMAIL PROTECTED]
-Original Message-
From: M. Sokolewicz [mailto:[EMAIL PROTECTED]
Sent: Friday, July 27, 2007 9:3
PROTECTED]
-Original Message-
From: Niel Archer [mailto:[EMAIL PROTECTED]
Sent: Friday, July 27, 2007 9:59 AM
To: php-windows@lists.php.net
Subject: Re: [PHP-WIN] Arrays past to functions
Hi Jacob
try this:
function compute_salestax ($Amount , $State)
{
$taxRate = array("CA&
-
Thanks for the help guys!
Jacob Bergman
Network Technician
Pullman School District #267
(509) 432-4012
[EMAIL PROTECTED]
-Original Message-
From: M. Sokolewicz [mailto:[EMAIL PROTECTED]
Sent: Friday, July 27, 2007 9:34 AM
To: Ja
Hi Jacob
try this:
function compute_salestax ($Amount , $State)
{
$taxRate = array("CA" => 5 , "WA" => 7, "OR" => 8);
return $Amount * $taxRate($state);
}
$payment = 1500;
$locale = 'CA';
print "Tax on $amount in $locale is " . compute_salestax ($payment ,
$locale);
--
ction and
pass it a state and amount for each state. Thanks for the reply.
Jacob Bergman
Network Technician
Pullman School District #267
(509) 432-4012
[EMAIL PROTECTED]
-Original Message-
From: Jarrett Meyer [mailto:[EMAIL PROTECTED]
Sent: Friday, July 27, 2007 8:56 AM
To: PHP Windows Li
TED]
Sent: Friday, July 27, 2007 8:56 AM
To: PHP Windows List
Subject: Re: [PHP-WIN] Arrays past to functions
You don't really need an array here.
function ComputeSalesTax($Amt, $State)
{
switch ($State)
{
case "CA":
$tax = 1.05;
"LA");
// fails
--
Jarrett M. T. Meyer
http://jarrettmeyer.blogspot.com
http://www.jarrettmeyer.com
- Original Message
From: Jacob Bergman <[EMAIL PROTECTED]>
To: php-windows@lists.php.net
Sent: Friday, July 27, 2007 11:46:19 AM
Subject: [PHP-WIN] Arrays past to functions
Hello all,
I am
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 a
Hi, can anyone walk me through arrays please.
I am new to PHP and arrays appear to come in many forms and I need help getting arrays
working properly.
Anything will be a great help, thanks,
Dan
data.
> but the address bar should not be hold if a large number of address
> presents.
> Is that have any suggestions??
> Thanks yours
>
> tarn@hk
>
> - Original Message -
> From: "Dash McElroy" <[EMAIL PROTECTED]>
> To: "H Marc Bower"
This worked wonderfully. Thanks, Dash.
- Original Message -
From: "Dash McElroy" <[EMAIL PROTECTED]>
Subject: Re: [PHP-WIN] arrays and nested arrays and loops and databases...
> If I understand correctly, you want to have an array containing an array
> with peop
rn@hk
- Original Message -
From: "Dash McElroy" <[EMAIL PROTECTED]>
To: "H Marc Bower" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, January 19, 2003 11:33 AM
Subject: Re: [PHP-WIN] arrays and nested arrays and loops and databases...
> If I u
If I understand correctly, you want to have an array containing an array
with people's email address and name from your db like this:
$to[0]['address'] = [EMAIL PROTECTED]
$to[0]['name'] = Bob Smith
$to[1]['address'] = [EMAIL PROTECTED]
$to[1]['name'] = John Jones
(the above is obviously not vali
Well... I can usually puzzle myself through these things, but I figured
it's time to ask the list. :) It may be a simple thing that I'm missing,
but here's what I have.
The structure that I'm trying to modify is as follows:
$to = array(
array(
with a
SELECT astatement then applying a second SELECT to that table???
- Original Message -
From: "Aidal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 16, 2002 10:59 PM
Subject: [PHP-WIN] Arrays - I may have gone blind
> Hi NG.
>
Hi NG.
I'm sure there is somthing implemented in PHP to do this but I just cant see
it.
I want to run through an array and remove some entries where is
true and is lower than the other entries of
First i thought... hmm this sounds like a linked list, I'm gonna make one.
But I cant seem to mak
27 matches
Mail list logo