note 55883 added to function.array-product

From: Date: Tue, 16 Aug 2005 15:17:27 +0000
Subject: note 55883 added to function.array-product
Groups: php.notes 
Request: Send a blank email to php-notes+get-93745@lists.php.net to get a copy of this message
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.) ---- Manual Page -- http://www.php.net/manual/en/function.array-product.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55883 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55883&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55883&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55883&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55883&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55883&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55883&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55883&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93745) next »