---
title: "PHP函数收藏---不断更新中!"
author: "eicesoft"
date: "2007-12-06T17:14:00Z"
tags: []
slug: "php"
draft: false
lastmod: "2007-12-06T17:14:00Z"
id: 674953
url: "https://eicesoft.iteye.com/blog/674953"
---

替换html标签 function strip\_bad\_tags($html) { $s = preg\_replace ("@?\[^&gt;]\*&gt;\*@", "", $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() &gt; 2 ? array\_diff($args,array($text)) : (array)$tags; foreach ($tags as $tag){ if(preg\_match\_all('/]\*&gt;(.\*)/iU', $text, $found)){ $text = str\_replace($found\[0],$found\[1],$text); } } return $text; }