You need to familiarize yourself with the DOMDocument class . The best way to do this is to parse the HTML using DOMDocumentand find all tags <img>using getElementsByTagName('img'). If these are the attributes of the images srcyou need, DOMDocument can return them and store them in an array.
$imgs = $dom->getElementsByTagName('img');
$img_src = array();
$to_remove = array();
foreach ($imgs as $img) {
$img_src[] = $img->getAttribute('src');
$to_remove[] = $img;
}
foreach ($to_remove as $node) {
$dom->removeChild($img);
}
source
share