Some people think that UBB is very difficult and do not know how to get started. In fact, it is very simple to replace regular expressions. The following is the code for converting UBB into HTML, which is only a small part. here we just want to make an example, this section describes how to convert UBB into HTML code that can be recognized by the browser. the Function preg_replace is mainly used. I will not introduce it here. For details, refer to the manual. In addition to this function, you can also use str_re. some people think that UBB is very difficult and do not know how to start with it. In fact, it is very simple to replace regular expressions. below is the code for converting some UBB into HTML, which is only a small part, this is just an example to illustrate how to convert UBB into HTML code that can be recognized by the browser, mainly the preg_replace function. I will not introduce it here. Read the manual for details, it is detailed. In addition to this function, you can also use functions such as str_replace.
You can add regular expression replacement to the $ match and $ replace arrays for extension.
Function ubb2html ($ strCodes ){ $ Match = array ( "% \ [B \] (. *?) \ [\/B \] % si ", "% \ [Center \] (. *?) \ [\/Center \] % si ", "% \ [Url \] (. *?) \ [\/Url \] % si ", "% \ [Url = (.*?) \] (. *?) \ [\/Url \] % si ", "% \ [Img \] (. *?) \ [\/Img \] % si ", "% \ [Fieldset = (.*?) \] (. *?) \ [\/Fieldset \] % si" ); $ Replace = array ( "$1", " $1 ", "$1 ", "$2 ", "550) this. width = 500 \" title = \ "Click here to browse the image in a new window \"> ", " $1
$2
" ); $ StrCodes = preg_replace ($ match, $ replace, $ strCodes );
Return $ strCodes; } ?> |