note 36153 added to function.empty

From: Date: Mon, 29 Sep 2003 01:02:39 +0000
Subject: note 36153 added to function.empty
Groups: php.notes 
Request: Send a blank email to php-notes+get-57241@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.empty.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36153 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36153&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36153&report=yes

« previous php.notes (#57241) next »