Home > Backend Development > PHP Tutorial > stuck_out_tongue_winking_eye is a ubbcode function, very fast

stuck_out_tongue_winking_eye is a ubbcode function, very fast

WBOY
Release: 2016-07-29 08:34:00
Original
1683 people have browsed it

I saw someone post it before
But it is slow and very long
Here is a
function ubb($str) {
$color=Array('red','blue','green');
$str =eregi_replace('[url]([a-zA-Z0-9@:%_.~#-?&]+)[/url]','\1< ;/a>',$str);//url
$str=eregi_replace('[url=http://([a-zA-Z0-9@:%_.~#-?&]+)] (.+)[/url]','
\2',$str);
$str=eregi_replace('[url=([a-zA- Z0-9@:%_.~#-?&]+)](.+)[/url]','\2' ,$str);
$str=eregi_replace('[img]([a-zA-Z0-9@:%_.~#-?&]+)[/img]','\1',$str);//img
$str=eregi_replace('[h([1-6])](.+)[/h[1-6] ]','\2',$str);//h1-6
$str=eregi_replace('[email]([_.0-9a-z-] +@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})[/email]','\1< ;/a>',$str);//email
$str=eregi_replace('[email=([_.0-9a-z-]+@([0-9a-z][0-9a-z -]+.)+[a-z]{2,3})](.+)[/email]','
\2',$str);
$str=eregi_replace('[b](.+)[/b]','\1',$str);
$str=eregi_replace('[i](.+) [/i]','\1',$str);
$str=eregi_replace('[size=(.+)](.+)[/size]','< ;font size=\1>\2',$str);
$str=eregi_replace('[color=(.+)](.+)[/color]','\2',$str);
$str=eregi_replace('[sub](.+)[/sub]','\1',$str );//下裱
$str=eregi_replace('[sup](.+)[/sup]','\1',$str);//superscript
for( $i=0;$i<=count($color);$i++)$str=eregi_replace('['.$color[$i].'](.+)[/'.$color[$i] .']','\1',$str);
$str=preg_replace("/[quote](.+? )[/quote]/is","

quote:
\1
$str=preg_replace("/[code](.+?)[/code]/is","
code:
\1
", $str) ;
$str=preg_replace("/[sig](.+?)[/sig]/is","


------------ -------------
\1
--------------------------< ;/div>", $str);
return $str;
}

The above introduces stuck_out_tongue_winking_eye, a ubbcode function, which is very fast and includes the content of stuck_out_tongue_winking_eye. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template