Home >php教程 >PHP源码 >php 图片地址处理

php 图片地址处理

PHP中文网
PHP中文网Original
2016-05-25 17:07:381351browse

[PHP]代码  

//图片地址处理
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;
}

                   

                   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn