Skip to content

Instantly share code, notes, and snippets.

@kaizhuQin
Last active July 26, 2016 04:07
Show Gist options
  • Save kaizhuQin/7194611 to your computer and use it in GitHub Desktop.
Save kaizhuQin/7194611 to your computer and use it in GitHub Desktop.
php:获取字符串中 img src 的路径
<?php
/**
* 获取字符串中 img src 的路径
* @param array $out[4] 图片路径数组
*/
public function GetImageSrc($body)
{
if(!isset($body)){
return '';
}else{
preg_match_all ("/<(img|IMG)(.*)(src|SRC)=[\"|'|]{0,}([h|\/].*(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG))[\"|'|\s]{0,}/isU",$body,$out);
return $out[4];
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment