Re: Array scanning stops by itself before reaching the end.
| From: | Bogdan Stancescu | Date: | Mon, 11 Feb 2002 03:36:18 +0000 |
| Subject: | Re: Array scanning stops by itself before reaching the end. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84211@lists.php.net to get a copy of this message | ||
Are you actually checking more than eight checkboxes? Otherwise you don't _get_ the ones which
are unchecked at all - that's the way it works. The ideal way to do this - if you have to do it
with arrays - is to walk
$Answer and check WHAT'S in there, rather than IF there is something in there. This obviously
assumes you're setting distinct values for the checked checkboxes in HTML.
Anyway, the first thing to try is to set more than eight checkboxes in HTML and see if you get the
error at different indexes.
HTH
Bogdan
"Raúl Sánchez T." wrote:
> I got this stupid problem:
> I create an HTML list of inputs: <input name="Answer[]"
> type='checkbox'> that stretches to some 25 elements.
>
> When I try to read the values ("on" or "off") with the code below, PHP
> won't read past the 8th. element and says it's found an undefined variable (which is $x).
> No matter what I do, it's always the 8th. element.
>
> for($x = 1; $x <= ($TotalAnswers); $x++)
> {
> echo($Answer[$x]);
> }
>
> Anyone has a prompt solution? I'm getting desperate.
> Thanks, Pepinho.