note 30686 deleted from function.array-count-values by alindeman
| From: | alindeman@php.net | Date: | Sat, 03 May 2003 21:07:25 +0000 |
| Subject: | note 30686 deleted from function.array-count-values by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47463@lists.php.net to get a copy of this message | ||
Hmmm.... This function didn't quite do what I was hopping it would. I needed something to
calculate all the numeric values in the array and return it so I just wrote this little function...
------------------------------------------------------------------
/**
* Calcuate sum of all values in array
*
* @author Richard Sumilang <richard@richard-sumilang.com>
* @param array $array Array of integers you want to sum
* @return integer
* @access public
*/
function array_count_values_2($array){
if(!is_array($array))
return "Please input an array";
foreach($array as $number){
if(is_numeric($number))
$count=$count + $number;
}
return $count;
}