how to retrive checkbox array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
suhail_anwar_khan
Forum Newbie
Posts: 11
Joined: Mon Jan 15, 2007 4:22 pm

how to retrive checkbox array

Post 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?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

they will be populated in your checkbox array. Unchecked ones will be absent.
suhail_anwar_khan
Forum Newbie
Posts: 11
Joined: Mon Jan 15, 2007 4:22 pm

Post by suhail_anwar_khan »

yes i get that but how will i retrive the "value" attribute from the array
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

var_dump() it.. you'll see.
suhail_anwar_khan
Forum Newbie
Posts: 11
Joined: Mon Jan 15, 2007 4:22 pm

Post 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[]
suhail_anwar_khan
Forum Newbie
Posts: 11
Joined: Mon Jan 15, 2007 4:22 pm

Post 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
Post Reply