I have a variable $content that contains some text and images in this form (unknown amount of images):
text text text text
$dom = new domDocument; $dom->loadHTML($html); $dom->preserveWhiteSpace = false; $imgs = $dom->getElementsByTagName("img"); $links = array(); for($i = 0; $i < $imgs->length; $i++) { $links[] = $imgs->item($i)->getAttribute("src"); }