php - How get first level of dom images src -


is way first value of image src without foreach?

$doc->loadhtml($description); foreach ($doc->getelementsbytagname('img') $image) { echo $image->getattribute('src'); } 

this not working $doc->getelementsbytagname('img')->item(0)->nodevalue);

this should work:

echo $doc->getelementsbytagname('img')->item(0)->getattribute('src'); 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -