我有一串设置为$content的数据,这个数据的一个例子如下
This is some sample data which is going to contain an image in the format <img src="http://www.randomdomain.com/randomfolder/randomimagename.jpg">. It will also contain lots of other text and maybe another image or two.
我试图只抓取<img src="http://www.randomdomain.com/randomfolder/randomimagename.jpg">
并将其保存为另一个字符串,例如 $extracted_image
到目前为止我有这个....
if( preg_match_all( '/<img[^>]+src\s*=\s*["\']?([^"\' ]+)[^>]*>/', $content, $extracted_image ) ) {
$new_content .= 'NEW CONTENT IS '.$extracted_image.'';
它返回的只是......
NEW CONTENT IS Array
我意识到我的尝试可能完全错误,但有人能告诉我哪里出错了吗?