note 86971 added to book.array
| From: | jorgeatandradedotcl at osu1 dot php dot net | Date: | Wed, 12 Nov 2008 20:03:48 +0000 |
| Subject: | note 86971 added to book.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146461@lists.php.net to get a copy of this message | ||
To calculate the average of a array
<?
function array_avg($array,$precision="2"){
$a=0;
if(is_array($array)){
foreach($array as $value):
if(!is_numeric($value)){
$a++;
}
endforeach;
if($a==0){
$cuantos=count($array);
return round(array_sum($array)/$cuantos,$precision);
}else{
return "ERROR in function array_avg(): the array contains one or more non-numeric
values";
}
}else{
return "ERROR in function array_avg(): this is a not array";
}
}
?>
----
Server IP: 190.54.16.132
Probable Submitter: 190.160.180.64
----
Manual Page -- http://www.php.net/manual/en/book.array.php
Edit -- https://master.php.net/note/edit/86971
Del: integrated -- https://master.php.net/note/delete/86971/integrated
Del: useless -- https://master.php.net/note/delete/86971/useless
Del: bad code -- https://master.php.net/note/delete/86971/bad+code
Del: spam -- https://master.php.net/note/delete/86971/spam
Del: non-english -- https://master.php.net/note/delete/86971/non-english
Del: in docs -- https://master.php.net/note/delete/86971/in+docs
Del: other reasons-- https://master.php.net/note/delete/86971
Reject -- https://master.php.net/note/reject/86971
Search -- https://master.php.net/manage/user-notes.php