RE: [PHP] checking if an array is empty
yeh wicked thanks -Original Message- From: Michael Sims [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 22, 2002 11:48 AM To: [EMAIL PROTECTED] Cc: electroteque Subject: Re: [PHP] checking if an array is empty On Sun, 22 Sep 2002 11:09:16 +1000, you wrote: >thats the thing , the word Array is what it returns even though there was no >input file. Oh, I see. Without seeing your code, the best recommendation I have is to loop through the array and remove the empty elements, then check to see if the array is empty, something like this: if (is_array($array)) { foreach ($array as $key => $element) { if ($element == "") { unset($array[$key]); } } } if (empty($array)) { ... } Sorry if I'm still misunderstanding... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking if an array is empty
On Sun, 22 Sep 2002 11:09:16 +1000, you wrote: >thats the thing , the word Array is what it returns even though there was no >input file. Oh, I see. Without seeing your code, the best recommendation I have is to loop through the array and remove the empty elements, then check to see if the array is empty, something like this: if (is_array($array)) { foreach ($array as $key => $element) { if ($element == "") { unset($array[$key]); } } } if (empty($array)) { ... } Sorry if I'm still misunderstanding... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking if an array is empty
thats the thing , the word Array is what it returns even though there was no input file. "Michael Sims" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Sun, 22 Sep 2002 01:13:08 +1000, you wrote: >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 I find that empty() works well to test if an array contains any elements... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking if an array is empty
On Sun, 22 Sep 2002 01:13:08 +1000, you wrote: >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 I find that empty() works well to test if an array contains any elements... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking if an array is empty
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] checking if an array is empty
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php