本帖最后由 zfm1988 于 2011-06-11 22:22:41 编辑

解决方案 »

  1.   

    这个很容易啊,用js现实最好<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    hello world,every thing is wrong
    </body>
    <script> 
    function HighLight(nWord){ if(nWord!=''){ var keyword = document.body.createTextRange(); while(keyword.findText(nWord)){ keyword.pasteHTML("<span style='color:red;'>" + keyword.text + "</span>"); keyword.moveStart('character',1); } } } function highword(nWord){ var array = nWord.split(","); for(var i=0;i<array.length;i++){ HighLight(array[i]); } } 
    HighLight('hello')
    </script>
    </html>
      

  2.   


    你这只是一种特例,你想想在一篇文章中,让指定都文字高亮,你着可以实现吗??就 google 搜索是高亮啊
      

  3.   

    呵呵,说说我的思路吧!!首先通过一个usort()函数,将数组安装内容长短,从大到小的排序,然后再通过preg_replace("/\b("word")\b/", '<u>\\1</>,$str);最后所以匹配到的东西都会有下划线的!!