Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJuan Henríquez
Courses Plus Student 2,485 PointsHow work the "values" and the "name" properties in php?
If I were working with PHP and in the form the user dials 2 or more checkboxes with the same "name" , that value will have the "name" when working with the back-end . All values would be stored in an array ?, because it is a variable ( "the name") with multiple values ("the values of the checkboxes ").
3 Answers
Lee Chavers
22,506 PointsYou'll need to make sure you are sending the information as an array.
For Example:
<input type="checkbox" name="something[]" value="Something 1">
<input type="checkbox" name="something[]" value="Something 2">
<input type="checkbox" name="something[]" value="Something 3">
<input type="checkbox" name="something[]" value="Something 4">
<input type="checkbox" name="something[]" value="Something 5">
In your php:
var_dump($_POST['something']);
This should show an array. Good luck!
Bill Dowd
7,681 PointsYes, they are an array because you put [] at the end of your variable name for the checkboxes.
Juan Henríquez
Courses Plus Student 2,485 PointsThanks to Lee and Bill, it was the explanation I needed.