Home > php教程 > PHP源码 > body text

PHP获取文章第一张图片做为缩略图

PHP中文网
Release: 2016-06-02 09:14:13
Original
2720 people have browsed it

PHP获取文章第一张图片做为缩略图

/**
 * 获取文章第一张图片做为缩略图
 * @param $content
* @return bool|string
*/
private static function thumb($content){
$contet = stripslashes($content);
if(preg_match_all("/(src)=([\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
$str = $matches[3][0];
$str = substr($str, 6);
if (preg_match('/upload/', $str)) {
return $str;
}
}
return '';
	}
Copy after login

                   

以上就是PHP获取文章第一张图片做为缩略图的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!