Re: checking if an array is empty
| From: | Sascha Cunz | Date: | Sat, 21 Sep 2002 15:33:25 +0000 |
| Subject: | Re: checking if an array is empty | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117101@lists.php.net to get a copy of this message | ||
There are many different states, in which an array would be empty. Can you
post the output of a "var_dump($array);" in that special case you want to
check?
In general:
1. the variable may not have been set:
if (!isset($myarray)) echo 'error';
2. the variable is set, but ain't an array:
if (!isarray($myarray) echo 'error';
3. the variable is set and is an array, but contains no data:
if (array_count($myarray) == 0) echo 'error';
I think the 3rd case could apply to your problem, but only a print_r or
var_dump of the $_POST['myarray'] can show this.
Sascha
Am Samstag, 21. September 2002 17:13 schrieb electroteque:
> how can i check if an array is currently empty , for instance i have a file
> input field with an array name for multiple images, i need to check if
> there was no file uploaded in that field name and ignore it in the loop