Last active
July 26, 2016 04:07
-
-
Save kaizhuQin/7194611 to your computer and use it in GitHub Desktop.
php:获取字符串中 img src 的路径
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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