Is the order of INPUTS in a POST guaranteed for array inputs in PHP?

瘦欲@ 提交于 2019-11-28 10:47:53

The W3 spec doesn't include rules on what order a form's values should be assembled into a data set, so technically you cannot be sure. On the other hand, I've not seen a case (from numerous browsers on numerous OSes over the years) where data hasn't been supplied in source-listing-order. I've not really tested for cases when changing the default (UI generated) tabindex values.

You could always sort the array (asort) after you've received it to be sure about what order you're reading values.

It's sort of guaranteed by HTML4.01 (for -urlencoded, but it's assumed to be identical for /form-data), and all current browsers submit the form fields in the order they are listed in the document.

So yes, they are ordered by their appearance, not by the random uuid.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!