这篇文章主要为大家详细介绍了php 简单的BBCode替换函数,具有一定的参考价值,可以用来参考一下。
为大家讲述一下一个简单的php BBCode替换函数 ,感兴趣的小伙伴,下面一起跟随四海网的小编罗X来看看吧。
/**
* BBCode替换函数
*
* @param
* @arrange (512.笔记) www.q1010.com
**/
function BBcode($texto){
$a = array(
"/\[i\](.*?)\[\/i\]/is",
"/\[b\](.*?)\[\/b\]/is",
"/\[u\](.*?)\[\/u\]/is",
"/\[img\](.*?)\[\/img\]/is",
"/\[url=(.*?)\](.*?)\[\/url\]/is",
"/\[size=(.*?)\](.*?)\[\/size\]/is",
);
$b = array(
"<i>$1</i>",
"<b>$1</b>",
"<u>$1</u>",
"<img src=\"$1\" />",
"<a href=\"$1\" target=\"_blank\">$2</a>",
'<font size=$1>$2</font>',
);
$texto = preg_replace($a, $b, $texto);
$texto = nl2br($texto);
return $texto;
}
if(isset($_GET['txt'])) {
echo "Has introducido: ".bbcode($_GET['txt']);
}
/*** 代码来自四海网(www.q1010.com) ***/
本文来自:http://www.q1010.com/173/494-0.html
注:关于php 简单的BBCode替换函数的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:BBCode
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。