Added helper method to check, if an array has only null-values.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user