Page 1 of 1

how to retrive checkbox array

Posted: Sun Jan 21, 2007 10:29 am
by suhail_anwar_khan
hi,
i have a group of checkboxes with all of their name fields marked as name=checkbox[]
in html for eg.

Code: Select all

<input type="checkbox" name="checkbox[]" value="foo1" />
<input type="checkbox" name="checkbox[]" value="foo2" />
etc.

now i want to write a php script to get the "value" attribute of the checked checkboxes so how can i do that?

Posted: Sun Jan 21, 2007 10:33 am
by Kieran Huggins
they will be populated in your checkbox array. Unchecked ones will be absent.

Posted: Sun Jan 21, 2007 10:39 am
by suhail_anwar_khan
yes i get that but how will i retrive the "value" attribute from the array

Posted: Sun Jan 21, 2007 10:40 am
by feyd
var_dump() it.. you'll see.

Posted: Sun Jan 21, 2007 10:43 am
by suhail_anwar_khan
i want to retrive this data which is sent by a html form and the checkbox entries are in an array chechbox[]

Posted: Sun Jan 21, 2007 10:47 am
by suhail_anwar_khan
thx a lot
i found the solution my self it was a minor mistake i didnt consider $_POST itself as an array

thx again 2 all