php转换ubb代码的实例

*文
发布: 2017-12-28 15:52:46
原创
1842人浏览过

本文主要介绍了php实现转换ubb代码的方法,涉及php正则替换的使用技巧。希望对大家有所帮助。本文实例讲述了php实现转换ubb代码的方法。分享给大家供大家参考。

具体如下:


function ubb2html($content)
{
global $article;
//是否自动识别
if ($article['isparseurl'] == "1")
{
$content = parseurl($content);
}
//自动识别结束
$content = eregi_replace(quotemeta("[b]"),quotemeta("<b>"),$content);
$content = eregi_replace(quotemeta("[/b]"),quotemeta("</b>"),$content);
$content = eregi_replace(quotemeta("[i]"),quotemeta("<i>"),$content);
$content = eregi_replace(quotemeta("[/i]"),quotemeta("</i>"),$content);
$content = eregi_replace(quotemeta("[u]"),quotemeta("<u>"),$content);
$content = eregi_replace(quotemeta("[/u]"),quotemeta("</u>"),$content);
$content = eregi_replace(quotemeta("[center]"),quotemeta("<center>"),$content);
$content = eregi_replace(quotemeta("[/center]"),quotemeta("</center>"),$content);
$content = eregi_replace(quotemeta("[quote]"),quotemeta("<table width="96%" border="0" cellspacing="3" cellpadding="0" style=word-break:break-all align="center"><tr><td><b>引用:</b></td></tr><tr><td><hr width="100%" noshade></td></tr><tr><td class="content"><font color="#0000FF">"),$content);
$content = eregi_replace(quotemeta("[/quote]"),quotemeta("</font></td></tr><tr><td><hr width="100%" noshade></td></tr></table>"),$content);
$content = eregi_replace(quotemeta("复制代码 代码如下:"),quotemeta("<table width="96%" border="0" cellspacing="3" cellpadding="0" style=word-break:break-all align="center"><tr><td><b>代码:</b></td></tr><tr><td><hr width="100%" noshade></td></tr><tr><td class="code"><font color="#0000FF">"),$content);
$content = eregi_replace(quotemeta(""),quotemeta("</font></td></tr><tr><td><hr width="100%" noshade></td></tr></table>"),$content);
$content = eregi_replace("\[images\]([^\[]*)\[/images\]","<a href="\1" target="_blank">@@##@@screen.width-333)this.width=screen.width-333" title="用新窗口浏览原始图片"></a>",$content);
$content = eregi_replace("\[url\]www.([^\[]*)\[/url\]", "<a href="http://www.\1" target=_blank>www.\1</a>",$content);
$content = eregi_replace("\[url\]([^\[]*)\[/url\]","<a href="\1" target=_blank>\1</a>",$content);
$content = eregi_replace("\[url=([^\[]*)\]([^\[]*)\[/url\]","<a href="\1" target=_blank>\2</a>",$content);
$content = eregi_replace("\[email\]([^\[]*)\[/email\]", "<a href="mailto:\1">\1</a>",$content);
//$content = preg_replace( '/javascript/i', 'java script', $content);
return $content;
}
登录后复制

相关推荐:

php 转换字符集的方法

php 字符串正则替换函数preg_replace使用详解

MVM mall 网上购物系统
MVM mall 网上购物系统

采用 php+mysql 数据库方式运行的强大网上商店系统,执行效率高速度快,支持多语言,模板和代码分离,轻松创建属于自己的个性化用户界面 v3.5更新: 1).进一步静态化了活动商品. 2).提供了一些重要UFT-8转换文件 3).修复了除了网银在线支付其它支付显示错误的问题. 4).修改了LOGO广告管理,增加LOGO链接后主页LOGO路径错误的问题 5).修改了公告无法发布的问题,可能是打压

MVM mall 网上购物系统 0
查看详情 MVM mall 网上购物系统

立即学习PHP免费学习笔记(深入)”;

关于php 字符串函数的详细介绍

php转换ubb代码的实例

以上就是php转换ubb代码的实例的详细内容,更多请关注php中文网其它相关文章!

相关标签:
php
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号