PHP/HTML - How to retain spaces in form input names?

两盒软妹~` 提交于 2020-01-25 03:19:36

问题


I have a form that has an input type=text and the name attribute has spaces in it.

When the form submits (it uses post) how can the spaces be retained, currently it replaces the spaces with underscores _


回答1:


Use arrays in the input names.

<input name="data[hello world]" type="text">

Then get the data in PHP using the 'data' key:

$_POST['data']['hello world']


来源:https://stackoverflow.com/questions/34464444/php-html-how-to-retain-spaces-in-form-input-names

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