It is necessary to obtain from the variable the exact value of all <img> tags. There can be several dozen of them and all of them are of different types, somewhere just img src , and somewhere with a full set of attributes, somewhere there can be <img .... /> , and somewhere just <img ...> . I would like to do this without using regular expressions and third-party libraries. I tried this:
$content=new DOMDocument(); $content->loadHTML($htmlcontent); $imgTags=$content->getElementsByTagName('img'); foreach($imgTags as $tag) { echo $tag->nodeValue; } But for some reason the result is not displayed. Although $tag->nodeName in this loop correctly displays the value of img . Please tell me where I have a mistake or how to solve the problem differently.
It is necessary to get exactly the exact integer value corresponding to <img ...> tag, and not one of its attributes. So that, depending on the conditions, cut a piece of this text from $ htmlcontent or leave it.