Answer the question
In order to leave comments, you need to log in
How to group form elements?
There is a form like this:
<form action="" method="post">
<input type="text" name="group[]" placeholder="группа">
<input type="text" name="text[]" placeholder="текст">
<input type="text" name="group[]" placeholder="группа">
<input type="text" name="text[]" placeholder="текст">
<input type="text" name="text[]" placeholder="текст">
<input type="submit" value="Отправить">
</form>
array(2) {
["group"]=>
array(1) {
['text']=>
string(14) "текст первой группы"
}
["group"]=>
array(2) {
['text']=>
string(36) "текст второй группы"
['text']=>
string(36) "текст второй группы"
}
}
Answer the question
In order to leave comments, you need to log in
Do it this way
<form action="" method="post">
<input type="text" name="group[0]" placeholder="группа">
<input type="text" name="group[0]['text'][]" placeholder="текст">
<input type="text" name="group[1]['text'][]" placeholder="группа">
<input type="text" name="group[1]['text'][]" placeholder="текст">
<input type="text" name="group[1]['text'][]" placeholder="текст">
<input type="submit" value="Отправить">
</form>
It's not very clear what you want.
But try putting each group in its own element <div>
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question