You are here: Slick way to check if array contains empty elements? « PHP Programming Language « IT news, forums, messages
Slick way to check if array contains empty elements?

Posted by laredotornado on 02/11/06 22:43

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.

$my_arr = array();
$my_arr[0] = "";
$my_arr[1] = "";
$all_empty = something($my_arr); // should contain the value TRUE

$my_arr = array();
$my_arr[0] = "";
$my_arr[1] = " hi ";
$my_arr[2] = "";
$all_empty = something($my_arr); // should contain the value FALSE

Any slick ways to find this out? - Dave

 

Navigation:

[Reply to this 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

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