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
Post a Comment