millken
高级会员

UID 73040
精华
0
积分 743
帖子 522
金钱 743 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2006-5-9 来自 REFERER
状态 在线
|
[推荐阅读] 如何只显示一条重复的记录啊?
老外的一个例子
唉,村里的这个高亮显示PHP代码的UBB不好用啊
[php]
//example
$q = array('foobar','string');
$str = 'this is a random string with the text foobar - bla bla
some text should be marked up.';
echo markup($str,$q);
function markup($content,$q)
{
$pattern = array();
$content = str_replace('<',' ',$content);
$content = str_replace('>',' ',$content);
foreach($q as $v)
{
$pattern[] = "/\b".$v."\b/i";
}
$content = preg_replace($pattern,'<b>\0</b>',$content);
$content = preg_replace('/\s+/', ' ',$content);
return $content;
}
?>
[ 本帖最后由 millken 于 2007-7-11 10:37 AM 编辑 ]
|  Blogger 免费搭建的个人BLOG |
|