Validating and Sanitizing Arrays in PHP


Apply filtering to arrays using filter_var_array() for validation and sanitization.

Source Code

$args = [
    "name" => FILTER_SANITIZE_STRING,
    "age" => [
        "filter" => FILTER_VALIDATE_INT,
        "options" => ["min_range" => 1, "max_range" => 120]
    ]
];
$input = filter_var_array($_POST, $args);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments