教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php匹配图片地址的代码一例

php匹配图片地址的代码一例

发布时间:2016-08-08   编辑:jiaochengji.com
本文介绍下,php中用正则匹配图片地址的一例代码,有需要的朋友参考下。

php正则匹配图片地址,代码如下:

<?php
//图片地址 正则匹配
//http://www.jbxue.com
function Getpics($body)
{
global $weburl;
//$body = strtolower($body);
$img_array = array();
preg_match_all("/(src|SRC)=[\"|'| ]{0,}((http|HTTP):\/\/(.*)\.(gif|jpg|GIF|JPG|png))/isU",$body,$img_array);
$img_array = array_unique($img_array[2]);
foreach($img_array as $key=&gt;$value)
{
$url = $value;
$fileurl = "/pic.php?s=".base64_encode($url);
$body = str_replace($url,$fileurl,$body);
}
return $body;
}
?>

您可能感兴趣的文章:
PHP正则匹配日期和时间(时间戳转换)的例子
php匹配任何网址的正则表达式
php正则匹配重写html图片img路径的代码一例
PHP正则匹配获取URL中域名的代码
使用 preg_replace 函数 匹配图片并加上链接的方法
php用preg_match_all匹配文章中的图片
php正则表达式匹配URL中的域名

您可能感兴趣的文章:
php匹配图片地址的代码一例
PHP正则匹配日期和时间(时间戳转换)的例子
php匹配任何网址的正则表达式
php正则匹配重写html图片img路径的代码一例
PHP正则匹配获取URL中域名的代码
php下载css中图片的实例代码
小议php正则提取图片地址
php正则匹配图片路径的方法参考
php下载css中图片函数
php preg_match_all匹配文章中图片

关键词: 图片地址   
[关闭]
~ ~