php實(shí)現(xiàn)轉(zhuǎn)換ubb代碼的方法
本文實(shí)例講述了php實(shí)現(xiàn)轉(zhuǎn)換ubb代碼的方法。分享給大家供大家參考。具體如下:
function ubb2html($content) { global $article; //是否自動(dòng)識(shí)別 if ($article['isparseurl'] == "1") { $content = parseurl($content); } //自動(dòng)識(shí)別結(jié)束 $content = eregi_replace(quotemeta("[b]"),quotemeta("<b>"),$content); $content = eregi_replace(quotemeta("[/b]"),quotemeta("</b>"),$content); $content = eregi_replace(quotemeta("[i]"),quotemeta("<i>"),$content); $content = eregi_replace(quotemeta("[/i]"),quotemeta("</i>"),$content); $content = eregi_replace(quotemeta("[u]"),quotemeta("<u>"),$content); $content = eregi_replace(quotemeta("[/u]"),quotemeta("</u>"),$content); $content = eregi_replace(quotemeta("[center]"),quotemeta("<center>"),$content); $content = eregi_replace(quotemeta("[/center]"),quotemeta("</center>"),$content); $content = eregi_replace(quotemeta("[quote]"),quotemeta("<table width=\"96%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" style=word-break:break-all align=\"center\"><tr><td><b>引用:</b></td></tr><tr><td><hr width=\"100%\" noshade></td></tr><tr><td class=\"content\"><font color=\"#0000FF\">"),$content); $content = eregi_replace(quotemeta("[/quote]"),quotemeta("</font></td></tr><tr><td><hr width=\"100%\" noshade></td></tr></table>"),$content); $content = eregi_replace(quotemeta("復(fù)制代碼 代碼如下:"),quotemeta("<table width=\"96%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" style=word-break:break-all align=\"center\"><tr><td><b>代碼:</b></td></tr><tr><td><hr width=\"100%\" noshade></td></tr><tr><td class=\"code\"><font color=\"#0000FF\">"),$content); $content = eregi_replace(quotemeta(""),quotemeta("</font></td></tr><tr><td><hr width=\"100%\" noshade></td></tr></table>"),$content); $content = eregi_replace("\\[images\\]([^\\[]*)\\[/images\\]","<a href=\"\\1\" target=\"_blank\"><img src=\"\\1\" border=0 onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\" title=\"用新窗口瀏覽原始圖片\"></a>",$content); $content = eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]", "<a href=\"http://www.\\1\" target=_blank>www.\\1</a>",$content); $content = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\1</a>",$content); $content = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$content); $content = eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\1</a>",$content); //$content = preg_replace( '/javascript/i', 'java script', $content); return $content; }
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
計(jì)算php頁(yè)面運(yùn)行時(shí)間的函數(shù)介紹
本篇文章是對(duì)計(jì)算php頁(yè)面運(yùn)行時(shí)間的函數(shù)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07php下關(guān)于Cannot use a scalar value as an array的解決辦法
已經(jīng)定義過的一個(gè)布爾型變量在下面被我直接當(dāng)數(shù)組來調(diào)用了,所以就出現(xiàn)錯(cuò)誤了2010-08-08PHP實(shí)現(xiàn)的簡(jiǎn)單組詞算法示例
這篇文章主要介紹了PHP實(shí)現(xiàn)的簡(jiǎn)單組詞算法,涉及php針對(duì)字符串的遍歷、遞歸、組合、運(yùn)算等相關(guān)操作技巧,需要的朋友可以參考下2018-04-04PHP+jQuery實(shí)現(xiàn)自動(dòng)補(bǔ)全功能源碼
前面手工寫了一個(gè)下拉自動(dòng)補(bǔ)全功能,寫的簡(jiǎn)單,只實(shí)現(xiàn)了鼠標(biāo)選擇的功能,不支持鍵盤選擇,下面與大家分享下PHP+jQuery實(shí)現(xiàn)自動(dòng)補(bǔ)全功能2013-05-05php 靜態(tài)屬性和靜態(tài)方法區(qū)別詳解
這篇文章主要介紹了php 靜態(tài)屬性和靜態(tài)方法區(qū)別詳解,需要的朋友可以參考下2017-04-04PHP 常用函數(shù)庫(kù)和一些實(shí)用小技巧
包括文件讀取函式,文件寫入函式,靜態(tài)頁(yè)面生成函式,目錄刪除函式等2009-01-01