Reply to Re: Slick way to check if array contains empty elements?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация