note 36153 deleted from function.empty by aidan

From: Date: Mon, 24 Jan 2005 14:33:29 +0000
Subject: note 36153 deleted from function.empty by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83862@lists.php.net to get a copy of this message
Note Submitter: Jan Smeelen / info AT Webfontein Dot nl ---- suppose you have an array like this : $file=array(''); ( for example with file uploads ) echo empty($file); output : FALSE ! I build a little function, to check, if the are empty values in the array : function empty_string_or_file($contr_file) { $return_value=1; if (is_array($contr_file)) { while(list($key,$val)=each($contr_file)) { if (!empty($val)) { $return_value=0; return $return_value; } } } elseif (!empty($contr_file)) { $return_value=0; } return $return_value; } for example : $file=array(''); echo 'file is empty = '.empty($file); ===> Output : file is empty = 0 echo 'file is empty ='.empty_string_or_file($file); ===> Output : file is empty = 1 echo 'string is empty='.empty_string_or_file("a"); ===> Output : file is empty = 0

« previous php.notes (#83862) next »