PHP Convert HTML code to UBB forum code_PHP tutorial
WBOY
Release: 2016-07-21 14:53:37
Original
872 people have browsed it
Lie16火84网(LieHuo24.Net) teaches17Cheng recently added a download section The one-click repost function, the Agni download column is built using DedeCMS. Everyone knows that dede does not have a one-click repost function, so I had to write one myself, and finally realized it. Write down the HTML to UBB code of the software introduction here.
One-click repost demonstration:
Regarding the problem of converting HTML to UBB code with PHP, the author found a few on the Internet, but they were not easy to use, so I modified and organized them myself. If you have other needs, you can leave a message below.
PHP code:
Copy to ClipboardQuoted content: [www.bkjia.com]
$intro = $liehuo-net; // Here is the variable value you obtained. $intro = str_replace("n",'',$intro); $intro = preg_replace("/]+HREF="([^"]+)"[ ^>]*>(.*?)/i","[url=$1]$2[/url]",$intro); $intro = preg_replace("/< font(.*?)color="#([^ >]+)"(.*?)>(.*?)/i","[color =$2]$4[/color]",$intro); $intro = preg_replace("/]+)"( .*?)>(.*?)/i","[face=$2]$4[/face]",$intro); $intro = preg_replace("/]+)"(.*?)>(.*?)/i", "[size=$2]$4[/size]",$intro); $intro = preg_replace("/]+src="([^"]+)"[^> ;]*>/i","[img]$1[/img]",$intro); $intro = preg_replace("/
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