i have large form that i want to send in mail using php, although i can send it with request['name'] i have to write it more than 50 times in message variable, what i want to do how i can add the keys and values to message variable with some filteration that i want to omit submit request variable
我有大型表格,我想用邮件发送邮件,虽然我可以发送请求['名称']我必须在消息变量写50多次,我想怎么做我怎么能添加密钥和值消息变量与一些过滤,我想省略提交请求变量
3 个解决方案
#1
I would make a copy of the variable, delete the submit
element and then get the array declaration code with var_export
:
我会复制变量,删除submit元素,然后使用var_export获取数组声明代码:
$array = $_REQUEST;
unset($array['submit']);
$text = var_export($array, true);
#2
http://php.net/filter_var_array might be what you're looking for.
http://php.net/filter_var_array可能就是你要找的东西。
#3
Doesn't foreach do exactly that ?
foreach不是那样做的吗?
foreach (filter_var_array($_REQUEST, ..) as $key => $value) {
echo $key.' => '.$value."\n";
}
Of course don't forget to filter the data itself.
当然不要忘记过滤数据本身。
#1
I would make a copy of the variable, delete the submit
element and then get the array declaration code with var_export
:
我会复制变量,删除submit元素,然后使用var_export获取数组声明代码:
$array = $_REQUEST;
unset($array['submit']);
$text = var_export($array, true);
#2
http://php.net/filter_var_array might be what you're looking for.
http://php.net/filter_var_array可能就是你要找的东西。
#3
Doesn't foreach do exactly that ?
foreach不是那样做的吗?
foreach (filter_var_array($_REQUEST, ..) as $key => $value) {
echo $key.' => '.$value."\n";
}
Of course don't forget to filter the data itself.
当然不要忘记过滤数据本身。