PHP -Sanitize values of a array

前端 未结 5 923
孤城傲影
孤城傲影 2020-12-01 09:33

I have a array, which comes from $_POST[] and can have other arrays in it as values, like:

array(
 \'title\' => \'Title\',
 \'data\' => ar         


        
5条回答
  •  醉话见心
    2020-12-01 10:19

    function strip($string, $allowed_tags = NULL)
    {
        if (is_array($string))
        {
            foreach ($string as $k => $v)
            {
                $string[$k] = strip($v, $allowed_tags);
            }
            return $string;
        }
    
        return strip_tags($string, $allowed_tags);
    }
    

    Just an example of a recursive function, for stripping tags in this case.

    $arr = strip($arr);
    

提交回复
热议问题