array in html form

Solutions on MaxInterview for array in html form by the best coders in the world

showing results for - "array in html form"
Thibault
02 Feb 2019
1You can also post multiple inputs with the same name and have them save into an array by adding empty square brackets to the input name like this:
2
3<input type="text" name="comment[]" value="comment1"/>
4<input type="text" name="comment[]" value="comment2"/>
5<input type="text" name="comment[]" value="comment3"/>
6<input type="text" name="comment[]" value="comment4"/>
7If you use php:
8
9print_r($_POST['comment']) 
10you will get this:
11
12Array ( [0] => 'comment1' [1] => 'comment2' [2] => 'comment3' [3] => 'comment4' )