note 76704 deleted from function.empty by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Nov 2008 22:07:39 +0000 |
| Subject: | note 76704 deleted from function.empty by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147302@lists.php.net to get a copy of this message | ||
Note Submitter: Talus (talusch dot no dot spam at gmail dot com)
----
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;
}
?>