php santize integer code example

Example: php sanitize $POST

//If the type of each of your input variables is a string and 
//you want to sanitize them all at once, you can use:
$_GET   = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
$_POST  = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
//or 
filter_var($_POST['message'], FILTER_SANITIZE_STRING);
//or
function util_array_trim(array &$array, $filter = false)
{
    array_walk_recursive($array, function (&$value) use ($filter) {
        $value = trim($value);
        if ($filter) {
            $value = filter_var($value, FILTER_SANITIZE_STRING);
        }
    });

    return $array;
}

Tags:

Php Example