我正在将表单数据分配到我的查询中。如果不是字母数字,我想将POST数据设置为null或删除特殊字符,其余的保持值?
有没有一种快速的方法可以批量完成这项工作?
if (!isset($_POST) || !ctype_alnum($_POST)){
// POST equals null
}else{
// Nothing
}
foreach($_POST as $key => $value)
{
if (empty($value) || !ctype_alnum($value))
{
// remove non alphanumeric chars
$_POST[$key] = preg_replace("/[^[:alnum:]]/i","",$value);
}
}