How to check if an array contains empty elements?
The answer depends on how you define "empty"
$contains_empty = count($array) != count(array_filter($array));
this checks for empty elements in the boolean sense. To check for empty strings or equivalents
$contains_empty = count($array) != count(array_filter($array, "strlen"));
To check for empty strings only (note the third parameter):
$contains_empty = in_array("", $array, true);
Try using in_array
:
return !in_array("", array("Paul", "", "Daniel")); //returns false