note 92308 added to function.empty
| From: | denobasis-bozicetyahoo dot com at osu1 dot php dot net | Date: | Sat, 18 Jul 2009 11:54:46 +0000 |
| Subject: | note 92308 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158456@lists.php.net to get a copy of this message | ||
test if all multiarray's are empty
function is_multiArrayEmpty($multiarray) {
if(is_array($multiarray) and !empty($multiarray)){
$tmp = array_shift($multiarray);
if(!is_multiArrayEmpty($multiarray) or !is_multiArrayEmpty($tmp)){
return false;
}
return true;
}
if(empty($multiarray)){
return true;
}
return false;
}
$testCase = array (
0 => '',
1 => "",
2 => null,
3 => array(),
4 => array(array()),
5 => array(array(array(array(array())))),
6 => array(array(), array(), array(), array(), array()),
7 => array(array(array(), array()), array(array(array(array(array(array(), array())))))),
8 => array(null),
9 => 'not empty',
10 => "not empty",
11 => array(array("not empty")),
12 => array(array(),array("not empty"),array(array()))
);
foreach ($testCase as $key => $case ) {
echo "$key is_multiArrayEmpty= ".is_multiArrayEmpty($case)."<br>";
}
OUTPUT:
========
0 is_multiArrayEmpty= 1
1 is_multiArrayEmpty= 1
2 is_multiArrayEmpty= 1
3 is_multiArrayEmpty= 1
4 is_multiArrayEmpty= 1
5 is_multiArrayEmpty= 1
6 is_multiArrayEmpty= 1
7 is_multiArrayEmpty= 1
8 is_multiArrayEmpty= 1
9 is_multiArrayEmpty=
10 is_multiArrayEmpty=
11 is_multiArrayEmpty=
12 is_multiArrayEmpty=
----
Server IP: 217.160.72.57
Probable Submitter: 79.210.86.53
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- https://master.php.net/note/edit/92308
Del: integrated -- https://master.php.net/note/delete/92308/integrated
Del: useless -- https://master.php.net/note/delete/92308/useless
Del: bad code -- https://master.php.net/note/delete/92308/bad+code
Del: spam -- https://master.php.net/note/delete/92308/spam
Del: non-english -- https://master.php.net/note/delete/92308/non-english
Del: in docs -- https://master.php.net/note/delete/92308/in+docs
Del: other reasons-- https://master.php.net/note/delete/92308
Reject -- https://master.php.net/note/reject/92308
Search -- https://master.php.net/manage/user-notes.php