note 76704 added to function.empty
| From: | (talusch.no.spam@gmail.com) | Date: | Thu, 26 Jul 2007 23:30:40 +0000 |
| Subject: | note 76704 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128953@lists.php.net to get a copy of this message | ||
Hello,
I made something better than fnbh at freemail dot hu in order to put more variables as an arg into
the empty function (like isset, you can put every var you want to, if one is not set, then it
returns false : the behaviour of this function will do the same, except that if one of the variables
if empty, then it returns true). But, I made it the simpliest way, and also i'm usign the
foreach structure, which is, i believe so, is better than the for structure for an array.
Here it comes :
<?php
function multi_empty(){
// -- If no parameters, then it is empty (just a matter of logic, nah ?).
if( func_num_args() == 0 ){
return true;
}
$args = func_get_args();
// -- Getting through all the arguments. If there's one which is empty, then we return true :
there is no reason to continue... ;)
foreach($args as $arg){
if( empty($arg) ){
return true;
}
}
// -- Nothing was found empty ; then the result is false.
return false;
}
?>
----
Server IP: 217.174.196.197
Probable Submitter: 86.207.134.56
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- https://master.php.net/note/edit/76704
Del: integrated -- https://master.php.net/note/delete/76704/integrated
Del: useless -- https://master.php.net/note/delete/76704/useless
Del: bad code -- https://master.php.net/note/delete/76704/bad+code
Del: spam -- https://master.php.net/note/delete/76704/spam
Del: non-english -- https://master.php.net/note/delete/76704/non-english
Del: in docs -- https://master.php.net/note/delete/76704/in+docs
Del: other reasons-- https://master.php.net/note/delete/76704
Reject -- https://master.php.net/note/reject/76704
Search -- https://master.php.net/manage/user-notes.php