I have an image in html. I parse it into a DOMDocument and start working with it ...
$doc = new DOMDocument(); $doc->loadHTML($article_header); $imgs = $doc->getElementsByTagName('img'); foreach ($imgs as $img) { $container = $img->parentNode; if ($container->tagName != "a") { $image_inside=utf8_decode($img->nodeValue); echo "3".$image_inside; die; } }
This code runs thin line 3 gets the image. line 6 understands that there is no "a" tag above this "img" tag, and line 8 should print my initial image. But I see only "3" without an image tag, etc ....
I checked the item and there was nothing. only 3 comes out. Why can't I print the image?
David source share