$content //要分离的内容
$dom = new \DOMDocument(); $arr_img_url = array(); $dom->loadHTML($content); //从字符串中加载HTML $img_url_list = $dom->getElementsByTagName('img'); //获取图片domif (!empty($img_url_list)) { foreach ($img_url_list as $key=>$item) { $img = $item->getAttribute('src'); //获取图片地址 $img_html[]=$dom->saveHTML($item); //把dom内容转化为html } }