/** * strip all HTML tags * * @link http://www.fileformat.info/info/unicode/version/1.1/index.htm Unicode 1.1 * * @param a string or an array * @param string of allowed tags, if any * @return a clean string or array */ public static function strip_tags($input, $allowed_tags = '') { // do it recursively if (is_array($input)) { foreach ($input as $name => $value) { $input[$name] = Surfer::strip_tags($value, $allowed_tags); } return $input; } // unmask HTML special chars $input = preg_replace('/&(#0*38|amp);/i', '&', $input); $input = preg_replace('/%u0*26/i', '&', $input); $input = preg_replace('/&(#0*60|lt);/i', '<', $input); $input = preg_replace('/%u0*3c/i', '<', $input); $input = preg_replace('/&(#0*62|gt);/i', '>', $input); $input = preg_replace('/%u0*3e/i', '>', $input); $input = preg_replace('/�*59;/i', ';', $input); // strip tags return strip_tags($input, $allowed_tags); }