替换html标签 function strip_bad_tags($html) { $s = preg_replace ("@]*>*@", "", $html); return $s; } 替换指定tag,$text是需要替换的文本,tags 是需要替换标签的数组 function strip_selected_tags($text, $tags = array()) { $args = func_get_args(); $text = array_shift($args); $tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags; foreach ($tags as $tag){ if(preg_match_all('/<'.$tag.'[^>]*>(.*)<\/'.$tag.'>/iU', $text, $found)){ $text = str_replace($found[0],$found[1],$text); } } return $text; }

相关文章:

  • 2022-12-23
  • 2022-01-23
  • 2021-11-30
  • 2021-08-30
  • 2022-12-23
  • 2021-12-18
  • 2021-12-15
  • 2021-12-02
猜你喜欢
  • 2021-08-14
  • 2021-09-06
  • 2022-01-12
  • 2021-09-17
  • 2019-01-20
  • 2021-11-27
  • 2021-05-22
相关资源
相似解决方案