note 99635 deleted from function.array-sum by danbrown
| From: | danbrown@php.net | Date: | Fri, 27 Aug 2010 17:19:55 +0000 |
| Subject: | note 99635 deleted from function.array-sum by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172116@lists.php.net to get a copy of this message | ||
Note Submitter: santos dot jcls at gmail dot com
----
function array_soma_campo( $array, $campo_soma, $campo_condicional, $codicao){
if(count($array) < 1 ){
return 0;
}
if( empty($campo_soma) ){
return 'Falta especificar campo!';
}
foreach ($array as $key => $value) {
if( empty($campo_condicional) ){
$valor += $value[strtolower($campo_soma)];
} else {
if($value[$campo_condicional]==strtoupper($codicao)){
$valor += $value[$campo_soma];
}
}
}
return $valor;
}