note 55883 deleted from function.array-product by victor
| From: | victor@php.net | Date: | Tue, 16 Aug 2005 15:28:34 +0000 |
| Subject: | note 55883 deleted from function.array-product by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93747@lists.php.net to get a copy of this message | ||
Note Submitter: Dave
Reason: useless
----
This is fairly trivial, but perhaps more useful than the array_product function. Note that this
function assumes that the array passed in contains numeric values.
//multiplies all the values in an array by $mult, returns the new array
function ArrayProd($array, $mult)
{
foreach(array_keys($array) as $key)
$array[$key] *= $mult;
return $array;
}
$percentages = array(.5532,.3723,.2967)
$percentages = ArrayProd($percentages, 100);
//$percentages now contains (55.32, 37.23, 29.67)
(this also works with associative arrays.)