note 50993 deleted from function.array-sum by salathe

From: Date: Mon, 21 Sep 2020 14:51:15 +0000
Subject: note 50993 deleted from function.array-sum by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215354@lists.php.net to get a copy of this message
Note Submitter: punchto at hotmail dot com ---- Microsoft Excel - SUMIF() function sumif($array,$criteria,$sum_array){ if(is_array($array) && is_array($sum_array) && trim($criteria)!= ""){ $array_count = (count($array) < count($sum_array)) ? count($array):count($sum_array); for($i=0;$i<$array_count;$i++){ if(ereg("^<",$criteria)){ $value = ereg_replace("^<","",$criteria); $result += $array[$i] < $value ? $sum_array[$i]:0; } elseif(ereg("^>",$criteria)){ $value = ereg_replace("^>","",$criteria); $result += $array[$i] > $value ? $sum_array[$i]:0; } else{ $value = $criteria; $result += $array[$i] == $value ? $sum_array[$i]:0; } } return $result ? $result:0; } }

« previous php.notes (#215354) next »