note 30686 added to function.array-count-values

From: Date: Tue, 25 Mar 2003 19:07:24 +0000
Subject: note 30686 added to function.array-count-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-45809@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; } -- http://www.php.net/manual/en/function.array-count-values.php http://master.php.net/manage/user-notes.php?action=edit+30686 http://master.php.net/manage/user-notes.php?action=delete+30686 http://master.php.net/manage/user-notes.php?action=reject+30686

« previous php.notes (#45809) next »