From 5b1be136ad6829e6fa5a4ba9bfc598f1d5a9509d Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Fri, 5 Oct 2018 17:11:06 +0200 Subject: [PATCH] Added helper method to check, if an array has only null-values. --- app/Http/helpers.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Http/helpers.php b/app/Http/helpers.php index 8587dbd..6eb734a 100644 --- a/app/Http/helpers.php +++ b/app/Http/helpers.php @@ -101,3 +101,21 @@ function endOfMonth($year, $month, $format='d.m.Y') { return Carbon\Carbon::createFromDate($year, $month) ->endOfMonth()->format($format); } + +/** + * Check, if all fields of an array are null. + * Returns true, if all fields of $array are null. Returns fals,e otherwise + * + * @param array $array + * @return boolean + */ +function allEmpty($array) +{ + foreach ($array as $item) { + if ($item !== null) { + return false; + } + } + + return true; +}