php ubb转换的简单示例

前端之家收集整理的这篇文章主要介绍了php ubb转换的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
对简单的PHP ubb转换代码感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * 简单的PHP ubb转换代码
 *
 * @param 
 * @arrange 网: www.www.jb51.cc
 **/
[b]test[/b]
[url=http://blah.com]blah[/url]
/***   来自编程之家 jb51.cc(jb51.cc)   ***/

will become:

/**
 * 简单的PHP ubb转换代码
 *
 * @param 
 * @arrange 网: www.www.jb51.cc
 **/
<strong>test</strong>
<a href="http://blah.com" target="_blank">blah</a>
/***   来自编程之家 jb51.cc(jb51.cc)   ***/
PHP

/**
 * 简单的PHP ubb转换代码
 *
 * @param 
 * @arrange 网: www.www.jb51.cc
 **/
function ubbcode($posting) {
	$posting=eregi_replace("\[img\]([^\[]+)\[/img\]","<img src=\"\\1\" border=\"0\">",$posting);
	$posting=eregi_replace("\[email\]([^\[]+)\[/email\]","<a href=\"mailto:\\1\">\\1</a>",$posting);
	$posting=eregi_replace("\[email=([^\[]+)\]([^\[]+)\[/email\]","<a href=\"mailto:\\1\">\\2</a>",$posting);
	$posting=eregi_replace("\[url=([^\[]+)\]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\2</a>",$posting);
	$posting=eregi_replace("\[url\]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$posting);
	$posting=eregi_replace("\[b\]","<strong>",$posting);
	$posting=eregi_replace("\[/b\]","</strong>",$posting);
	$posting=eregi_replace("\[u\]","<u>",$posting);
	$posting=eregi_replace("\[/u\]","</u>",$posting);
	$posting=eregi_replace("\[i\]","<em>",$posting);
	$posting=eregi_replace("\[/i\]","</em>",$posting);
	return $posting;
}
/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528601.html

猜你在找的PHP相关文章