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=>$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中的域名