|
Posted by Marcin Dobrucki on 02/13/06 15:03
laredotornado@zipmail.com wrote:
> Hi,
>
> Wondered if there was a good one-liner for what I want to do in PHP 4.
> I have an array, with an arbitrary number of elements. I'd like to
> know if all the elements in the array are empty. If at least one
> element is non-empty, then the entire condition is false.
function isEmpty($array = array()) {
foreach ($array as $element) {
if (!empty($element)) {
return false;
}
}
return true;
}
Okay, maybe not quite one-liner, but it should do the trick.
Ofcourse, it does depend if you agree with "empty"'s definition of what
empty is.
/Marcin
Navigation:
[Reply to this message]
|