私はこのコードを使用しますPHPを使用して文字列の最初のイメージを取得するには?
<?php
$texthtml = '<p>test</p><br><p><img src="1.jpeg" alt=""><br></p><p><img src="2.png" alt=""><br><img src="3.png" alt=""></p>';
preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $texthtml, $image);
echo $image['src'];
?>
はしかし、私はそれをテストするとき、私は、文字列から最後の画像(3.png)
を取得します。
最初の画像(1.jpeg)
を文字列で取得するにはどうすればよいか知りたいです。