/*
content=文章内容;
order=ALL 所有图片
order=1 第一章图
*/
function getImgs($content,$order='ALL'){
$pattern = "/<img .*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$content,$match);
if(isset($match[1]) && !empty($match[1])){
if($order==='ALL'){
return $match[1];
}
if(is_numeric($order) && isset($match[1][$order])){
return $match[1][$order];
}
}
return '';
}
$wzpics=getImgs(htmlspecialchars_decode($jieshao));分类: 程序开发 / Tags: php 提取文章中所有图片

网友品论
留下您的评论