I have a bunch of checkboxes declared as follows:
<input name="ptProb[]" type="checkbox"
"<? if($ptProb[0] != 0) echo 'checked'; ?> "/>
<input name="ptProb[]" type="checkbox"
"<? if($ptProb[1] != 0) echo 'checked'; ?> "/>
The checkboxes are to be eventually stored in a datbase in an array, like
ptProb[0] = 1
ptProb[1] = 0
ptProb[2] = 0
ptProb[3] = 1 etc.
(If the value read from the database is "1" then the checkbox will be checked initially)
As I understand it, if the user checks a particular checkbox, I can access it using $_POST['ptProb'].
If checkbox #1, #3, #5 and #10 are checked, print_r gives me the following output:
Array ( [0] => on
[1] => on
[2] => on
[3] => on )
However the index shown above does not correspond to the checkbox that was selected. What I actually need is something like this:
Array ( [1] => on
[3] => on
[5] => on
[10] => on )
How do I find the correct index of the checkbox?
Thank you for any help/suggestions.