获取所有图像并返回src


Get all images and return the src

下面的代码抓取了一些内容。在这个内容中有一些照片。我怎么能通过这个内容循环找到所有的图像和返回他们的src?

我的代码到目前为止:

$items = $html->find('div.post-single-content',0)->children(1)->outertext;
foreach($items $node) { 
$node->find('img');
}
print_r ($node);

不要使用正则表达式,使用解析器。例子:

$string = '<img src="You want this" style="width:200px;" />';
$doc = new DOMDocument();
$doc->loadHTML($string);
$images = $doc->getElementsByTagName('img');
foreach ($images as $image) {
     echo $image->getAttribute('src') . "'n";
}
输出:

你想要这个