Added helper method to check, if an array has only null-values.

This commit is contained in:
Lukas Halbritter
2018-10-05 17:11:06 +02:00
parent ac49d3857f
commit 5b1be136ad
+18
View File
@@ -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;
}