note 39982 deleted from language.types.boolean by nlopess

From: Date: Tue, 17 Feb 2004 16:40:34 +0000
Subject: note 39982 deleted from language.types.boolean by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-65309@lists.php.net to get a copy of this message
Note Submitter: cvlad at wallaquia ---- When you are doing a if ($array) to find whether an array is empty or not you´ll returning a true in the case of a multidimensional array filled with empty arrays. The reason it occurs is that, well, actually the array is not empty, it is filled with empty arrays! :-) But eventually I found useful to know if the array is all-along empty, so I've written this simple function (I don´t know if there is some other form of doing this). Hope you find useful. function arrayVazio($array) { if (is_array($array)) { if ($array) { $retorno = true; foreach ($array as $a) { $retorno &=arrayVazio($a); } return $retorno; } else { return true; } } else { return false; } }

« previous php.notes (#65309) next »