PHP Manual: filter_var_array()
mixed filter_var_array ( array $data [, mixed $definition [, bool $add_empty = true ]] )
Can something like
Just make sure you do not put the flags inside their own array. Options can be in an array, but the flags need to be seen as one whole thing separated by the bitwise OR operator (|
).
$def = [
'firstName' => ['filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_REQUIRE_SCALAR | FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH],
'lastName' => ['filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_REQUIRE_SCALAR | FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH]
];