PHP/HTML-如何在表单输入名称中保留空格? [英] PHP/HTML - How to retain spaces in form input names?

查看:87
本文介绍了PHP/HTML-如何在表单输入名称中保留空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有输入 type = text 的表单,并且 name 属性中包含空格.

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

表单提交时(使用 post )如何保留空格,当前它用下划线 _

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

推荐答案

在输入名称中使用数组.

Use arrays in the input names.

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

然后使用数据"键在PHP中获取数据:

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

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

这篇关于PHP/HTML-如何在表单输入名称中保留空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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