递归处理数组的问题请教

WBOY
Release: 2016-06-23 13:40:16
Original
943 people have browsed it

由于在PHP5.4.3以上,PHP不再支持magic_quotes_gpc功能,所以想直接透过
if (PHP_VERSION >= 5.4 || !get_magic_quotes_gpc())
{
$_REQUEST = array_map( 'addslashes', $_REQUEST);
$_POST = array_map( 'addslashes', $_POST);
$_GET = array_map( 'addslashes', $_GET);
}
来解决用户提交数据中的',‘’问题,但发现array_map函数无法解决递归的问题,如果控件名称是多个同名的,类似ck[],而
采用array_walk_recursive,又回提示Fatal error: Call-time pass-by-reference has been removed ,请问PHP5.4.3以上版本可有函数解决这个问题


回复讨论(解决方案)

http://bbs.csdn.net/topics/390936241

可以参考下

array_walk_recursive($_POST, function(&$v) { $v = addslashes($v); });
Copy after login
其他类同

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template