表单数组支持跨浏览器 [英] Form Arrays support across browsers

查看:90
本文介绍了表单数组支持跨浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < p< p>< p>< ; input name ='element []'type ='text'/> 
< input name ='element []'type ='text'/>

然后在PHP中以 $ _ POST ['元素'] - 在这种情况下有2个值。



我已经在我可用的浏览器中测试过了,但是我以前从未见过这个,我想知道这在所有浏览器中都很受支持吗?或者,这是我刚才没有遇到的那个旧东西?



谢谢!

解决方案

它是服务器端语言,它将它变成一个数组(大多数语言不要求名称以 [] 结尾),这是奇怪的PHP)。

就浏览器而言,它只是一堆具有相同名称的输入,使用提交表单的标准规则进行序列化数据。即

  element [] = value& element [] = value 

浏览器没有任何问题。它已经以这种方式工作,因为HTML首先得到 form 元素。


I'm not even sure if form arrays is the proper term, but it looks a bit like this:

<input name='element[]' type='text' />
<input name='element[]' type='text' />

Which is then retrieved in PHP as an array stored in $_POST['element'] -- in this case with 2 values.

I've tested it in the browsers I have available to me, but I've never seen this before and I'm wondering is this supported pretty much in all browsers? Or is this something very old that I've just not run into?

Thanks!

解决方案

It is the server side language that turns this into an array (most languages don't require the name to end in [], that is an oddity of PHP).

As far as the browser is concerned, it is just a bunch of inputs with the same name, that get serialized using the standard rules for submitting form data. i.e.

element[]=value&element[]=value

No browser has any problems with this. It has worked this way since HTML first got a form element.

这篇关于表单数组支持跨浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆