美文网首页
php 获取到富文本中的图片

php 获取到富文本中的图片

作者: 风度翩翩的程序猿 | 来源:发表于2023-02-08 15:39 被阅读0次
 // 截取富文本中的图片
    public 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 [];
    }

相关文章

网友评论

      本文标题:php 获取到富文本中的图片

      本文链接:https://www.haomeiwen.com/subject/ipmqkdtx.html