From 9e278a9370e3b651a4a545c0c0c0c256088ed187 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 24 Jun 2016 08:50:57 -0400 Subject: Use BoardFormatter to generate the board --- app/functions.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'app/functions.php') diff --git a/app/functions.php b/app/functions.php index b759763f..99431d9e 100644 --- a/app/functions.php +++ b/app/functions.php @@ -2,6 +2,32 @@ use Kanboard\Core\Translator; +/** + * Sum all values from a single column in the input array + * + * $input = [ + * ['column' => 2'], ['column' => 3'] + * ] + * + * array_column_sum($input, 'column') returns 5 + * + * @param array $input + * @param string $column + * @return double + */ +function array_column_sum(array &$input, $column) +{ + $sum = 0.0; + + foreach ($input as &$row) { + if (isset($row[$column])) { + $sum += (float) $row[$column]; + } + } + + return $sum; +} + /** * Build version number from git-archive output * -- cgit v1.2.3