Re: Parsing an array from a posted form
| From: | 1LT John W. Holmes | Date: | Wed, 20 Nov 2002 20:07:23 +0000 |
| Subject: | Re: Parsing an array from a posted form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125315@lists.php.net to get a copy of this message | ||
> I have a form that is being passed to a mail function when submitted. It
is
> working OK, except that I am having trouble with values from arrays such
as
> checkbox lists. For example, I have a list such as:
>
> <input type="checkbox" name="graphicFormat[]" value="eps"
> /> .eps
> <input type="checkbox" name="graphicFormat[]" value="jpg"
> /> .jpg
> <input type="checkbox" name="graphicFormat[]" value="tif"
> /> .tif
> <input type="checkbox" name="graphicFormat[]" value="gif"
> /> .gif
> <input type="checkbox" name="graphicFormat[]" value="png"
> /> .png
> <input type="checkbox" name="graphicFormat[]" value="psd"
> /> .psd
> <input type="checkbox" name="graphicFormat[]" value="bmp"
> /> .bmp
> <input type="checkbox" name="graphicFormat[]" value="other"
> /> other
>
> I am using something like:
>
> for ($z=0;$z<count($graphicFormat);$z++) {
> $graphicFormat = stripslashes($graphicFormat[$z]);
> }
>
> Which will return a count of the number of items in the array. What I want
> returned is a string of the values selected such as:
>
> "eps, gif, other"
$string = implode(",",$graphicFormat);
To see how many checkboxes were selected, use
$num = count($graphicFormat);
---John Holmes...