Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
foreachなしで画像srcの最初の値を取得する方法はありますか?
$doc->loadHTML($description); foreach ($doc->getElementsByTagName('img') as $image) { echo $image->getAttribute('src'); }
これは機能していません$doc->getElementsByTagName('img')->item(0)->nodeValue);
$doc->getElementsByTagName('img')->item(0)->nodeValue);
これは機能するはずです:
echo $doc->getElementsByTagName('img')->item(0)->getAttribute('src');