在Form Submit上调用一个函数,然后将变量传递给函数

I have a PHP function to strip any dodgy characters that may be used maliciously.

<?php
    function strip_tags_content($text, $tags = '', $invert = FALSE) { 
        preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags); 
        $tags = array_unique($tags[1]); 

        if(is_array($tags) AND count($tags) > 0) { 
            if($invert == FALSE) { 
                return preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text); 
            } 

            else { 
                return preg_replace('@<('. implode('|', $tags) .')\b.*?>.*?</\1>@si', '', $text); 
            } 
        } 

        else if($invert == FALSE) { 
            return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text); 
        } 

        return $text; 
    }
?>

I have a Sign Up form above this function and I want to pass every single form input through this function to have it stripped of all characters.

How would I do this?

$stripped = array();
foreach($_POST as $index => $value){
    $stripped[$index] = strip_tags_content($value);
}