PHP implementation of the conversion Ubb code method

Source: Internet
Author: User

This article illustrates how PHP implements the transformation of UBB code. Share to everyone for your reference. as follows:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28-29 The function ubb2html ($content) {Global $article//is automatically recognized if ($article [' isparseurl '] = = "1") {$content = parseURL ($content ); }//Automatic identification End $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> Reference: </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 (<div class=codetitle><span><a style= "Cursor:pointer" id= copybut96967 class=copybut onclick= "docopy (' code96967 ')" Data= "96967" ><U> copy code </u></a></ Span> code is as follows: </div><div id=code96967 class=codebody> "), Quotemeta (" <table width= "96%" border= "" 0 " cellspacing= "3" cellpadding= "0" style=word-break:break-all align= "center" ><tr><td><b> Code:< /b></td></tr><tr><td><hr width= "100%" noshade></td></tr><tr> <TD class= "code" ><font color= "#0000FF" >), $content); $content = Eregi_replace (quotemeTa ("</DIV>"), 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= "Browse the original picture with a new window" ></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; }

I hope this article will help you with your PHP programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.