note 39982 added to language.types.boolean

From: Date: Tue, 17 Feb 2004 16:39:47 +0000
Subject: note 39982 added to language.types.boolean
Groups: php.notes 
Request: Send a blank email to php-notes+get-65308@lists.php.net to get a copy of this message
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; } } ---- Manual Page -- http://www.php.net/manual/en/language.types.boolean.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39982 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39982&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39982&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65308) next »