$dom = new DOMDocument(); $dom->loadHtml($yourHtmlAsAString); foreach ($dom->getElementsByTagName('img') as $img) { echo $img->getAttribute('src').'<br>'; // or whatever you need }