4

从这样的元素命名是否有任何已知问题或缺点:

<form method="POST" ... >
    <input name="category[title]" ...>
    <input name="category[desc]" ...>
</form>

结果POST将是这样的:

Array 
(
    [category] => Array
        (
            [title] => 0
            [desc] => 0
        )
)

它适用于所有主要的网络浏览器吗?还有它的具体名称吗?

4

1 回答 1

2

核实:

/* send a object like it:
Person:
{
 name: 'Homer'
 age : 50
 kids :[
  { name: 'Liza', age: 9 }, 
  { name: 'Bart', age: 8 }, 
  {name: 'Maggie', age: 2 }
 ]}
 */
<form method="post" action='my_magic_form.xpto'>
    <input type="text" name="name" placeholder="Your Name" />
    <input type="text" name="age" placeholder="Your age" />
    <input type="text" name="kids[0].name" placeholder="First child name" /> 
    <input type="text" name="kids[0].age" placeholder="First child age" />
    <input type="text" name="kids[1].name" placeholder="Second child name" />
    <input type="text" name="kids[1].age" placeholder="Second child age" /> 
    <input type="text" name="kids[2].name" placeholder="Third child name" /> 
    <input type="text" name="kids[2].age" placeholder="Third child age" />
</form>

于 2015-02-03T03:20:47.300 回答