获取文章html中的img标签图片src地址

发表日期:2022-08-06 15:42:56 | 来源: | | 浏览(836) 分类:PHP杂项

/**
 * 获取文章中的图片
 * @param $content
 * @return mixed
 */
function html_get_img($content)
{
//    强力模式
//    preg_match_all('#<[img|IMG].*?[src|SRC]=[$"|$\'|$\s]*([^"|^\'|^\s]*)[^>]*>#i', $content, $match);
    preg_match_all('#<[img].*?[src]="([^"]*)[^>]*>#i', $content, $match);
    return $match[1];
}


集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。