会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
MultiThread-PHP
PHP扩展编程,感兴趣的加qq群:95303036
博客园
首页
新随笔
联系
订阅
管理
php查找字符串中的http地址,并转换
function convertImg($str) { $str = preg_replace("/\{([^}]+)\}/",'<div style="border:1px dashed #003366; background-color:#f0f0f0; height:21px; color:#003399">回复:$1</div>',preg_replace("/\[(\d+)\]/",'<img src="/images/face/face$1.jpg"/>',$str)); $reg="/http\:\/\/(\w+\.)+(net|com|org|cn|kr|jp|tw)[A-Za-z0-9_&\/\?=]*/i"; if(preg_match_all($reg,$str,$out)) { for($i=0;$i<count($out[0]);$i++) { $link=substr(base64_encode(md5(preg_replace("/http\:\/\//","",$out[0][$i]))),0,10+strlen($str)%10); $str=str_replace($out[0][$i],'<a href="'.$out[0][$i].'">http://'.$link.'</a>',$str); } } return $str; }
posted @
2011-11-30 18:35
MultiThread-PHP
阅读(
549
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告