0

我还需要获取 img标签信息(<img src="images/construction.jpg" border="0" alt="" />)我需要做什么函数和代码修改,因为我使用的这个代码在我的foreach循环中,因为数据是从数据库中迭代的。

我的工作代码---

<?php

$content = '<p><img src="images/construction.jpg" border="0" alt="" />This is only a testing phase data</p>';

$content = preg_replace("/<img[^>]+\>/i", "", $content);

echo $content;  //OUTPUT --  This is only a testing phase data

?>
4

1 回答 1

2

您需要使用preg_match来检索该数据,而不是preg_replace.

于 2012-07-09T08:33:57.640 回答