
是的,可以在 PHP 中将 filter_input() 与 AND/OR 结合起来。这可以通过循环 POST 字段来完成 –
$value = filter_input(INPUT_POST, 'field', FILTER_DEFAULT, is_array($_POST['field']) ? FILTER_REQUIRE_ARRAY : NULL);
登录后复制
每个循环的同一用户的等效项如下所示 –
$memory = array();
//looping through all posted values
foreach($_POST as $key => $value) {
//applying a filter for the array
if(is_array($value)) {
$ memory [$key] = filter_input(INPUT_POST, $key, {filters for array});
}
else {
$ memory [$key] = filter_input(INPUT_POST, $key, {filters for scalar});
}
}
登录后复制
以上就是能否将PHP的filter_input()过滤器标志与AND/OR结合使用?的详细内容,更多请关注php中文网其它相关文章!