文章给你分享一篇简单的关于ubb代码如何利用php来解析哦,我们主要用到了preg_replace()函数,有了其它一切都好做
代码如下 | 复制代码 |
/** ",$Text); $Text=preg_replace("/[separator]/is"," ",$Text); $Text=preg_replace("/[h1](.+?)[/h1]/is"," \1",$Text);$Text=preg_replace("/[h2](.+?)[/h2]/is"," \1",$Text);$Text=preg_replace("/[h3](.+?)[/h3]/is"," \1",$Text);$Text=preg_replace("/[h4](.+?)[/h4]/is"," \1",$Text);$Text=preg_replace("/[h5](.+?)[/h5]/is"," \1",$Text);$Text=preg_replace("/[h6](.+?)[/h6]/is"," \1",$Text);$Text=preg_replace("/[center](.+?)[/center]/is"," //$Text=preg_replace("/[url=([^[]*)](.+?)[/url]/is","\2",$Text); $Text=preg_replace("/[url](.+?)[/url]/is","\1",$Text); $Text=preg_replace("/[url=(http://.+?)](.+?)[/url]/is","\2",$Text); $Text=preg_replace("/[url=(.+?)](.+?)[/url]/is","\2",$Text); $Text=preg_replace("/[img](.+?)[/img]/is"," $Text=preg_replace("/[imgs(.+?)](.+?)[/img]/is"," $Text=preg_replace("/[color=(.+?)](.+?)[/color]/is","\2",$Text); $Text=preg_replace("/[colorTxt](.+?)[/colorTxt]/eis","color_txt('\1')",$Text); $Text=preg_replace("/[style=(.+?)](.+?)[/style]/is"," \2 ",$Text); $Text=preg_replace("/[size=(.+?)](.+?)[/size]/is","\2",$Text); $Text=preg_replace("/[sup](.+?)[/sup]/is","\1",$Text); $Text=preg_replace("/[sub](.+?)[/sub]/is","\1",$Text); $Text=preg_replace("/[pre](.+?)[/pre]/is"," \1",$Text); $Text=preg_replace("/[emot](.+?)[/emot]/eis","emot('\1')",$Text); $Text=preg_replace("/[email](.+?)[/email]/is","\1",$Text); $Text=preg_replace("/[i](.+?)[/i]/is","\1",$Text); $Text=preg_replace("/[u](.+?)[/u]/is","\1",$Text); $Text=preg_replace("/[b](.+?)[/b]/is","\1",$Text); $Text=preg_replace("/[quote](.+?)[/quote]/is"," 引用:", $Text); $Text=preg_replace("/[code](.+?)[/code]/eis","highlight_code('\1')", $Text); $Text=preg_replace("/[php](.+?)[/php]/eis","highlight_code('\1')", $Text); $Text=preg_replace("/[sig](.+?)[/sig]/is"," -------------------------- \1 -------------------------- return $Text; } |
关于preg_replace()函数语法
preg_replace函数基础与实例代码
//preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] ) 主题为匹配搜索模式,替换替换
/*
要搜索的模式。它可以是一个字符串或一个字符串数组。
电子修饰符使preg_replace函数()替代治疗后,适当引用作为参数是php教程代码进行替换。提示:请确保置换构成一个有效的php代码字符串,否则php将抱怨在包含preg_replace函数线()解析错误。
返回值
preg_replace函数()返回一个数组,如果这个问题的参数是一个数组或一个字符串,否则。
如果找到匹配,新问题会产生,否则将返回主题不变或null如果发生错误。
更多详细内容请查看:http://www.bKjia.c0m/phper/php-function/33530.htm

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

記事本++7.3.1
好用且免費的程式碼編輯器

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。