Re: using an array with form list values
| From: | Philip Hallstrom | Date: | Thu, 03 May 2001 20:24:28 +0000 |
| Subject: | Re: using an array with form list values | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-51324@lists.php.net to get a copy of this message | ||
Something like this should help:
if( is_array($preferred_location) ) {
#your code goes here.
}
In article <9csden$8qu$1@toye.p.sourceforge.net> you write:
>I need to check that a form entry defined as an array contains a value
>before initiating the foreach code in my script.
>
>I have my form field defined in my form as:
>
><?php
> print '
> <select name="preferred_location[]"size="3"
> MULTIPLE>
> <option value="Bermuda">Bermuda</option>
> <option value="California">California</option>
> <option value="Caribbean">Caribbean</option>
> <option value="Carolinas">Carolinas</option>
> <option
>value="Florida-Atlantic">Florida-Atlantic</option>
> <option value="Florida-Gulf coast">Florida-Gulf
>coast</option>
> <option value="Florida-Pan handle">Florida-Pan
>handle</option>
> <option value="Hawaii">Hawaii</option>
> <option
> value="Mediterranean">Mediterranean</option>
> <option value="Mexico">Mexico</option>
> <option
>value="S.Pacific/Autralia">S.Pacific/Autralia</option>
> </select>';
> ?>
>
>And my script code as:
>
> foreach ( $preferred_location as $location )
> {
> $msg .= "$location\n";
> }
>
>As long as the user selects at least one form value from the list box, the
>script processes without error. If no item is selected -- This msg is
>rcved:
>
>Warning: Non array argument supplied for foreach() in
>/usr/local/etc/httpd/htdocs/test/beaches/beaches_quote.scp.php3 on line 30
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>