Re: is there a builtin php function for this ?
| From: | Monte Ohrt | Date: | Wed, 10 Jan 2001 17:22:34 +0000 |
| Subject: | Re: is there a builtin php function for this ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33710@lists.php.net to get a copy of this message | ||
echo array_sum($price) * tax;
array_sum() was added to PHP 4.0.4.
Chris Lee wrote:
>
> <?
> function add_all($array)
> {
> foreach($array as $pos => $val)
> @$sum += $val;
> return @$sum;
> }
>
> $price[123] = 5;
> $price[123] = 2;
> $price[123] = 7;
> $price[123] = 9;
>
> $tax = 0.14;
>
> echo add_all($price) * $tax;
> ?>
>
> is there a built in function to replace add_all, I would like to have a
> add_all, multiply_all, divide_all, etc etc. a php function would just be
> nicer...
>
> Chris Lee
> Mediawaveonline.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/