【问题标题】:String to retrieve that im omitting using preg_replace使用 preg_replace 检索忽略的字符串
【发布时间】:2012-07-09 08:28:10
【问题描述】:

我还需要获取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

?>

【问题讨论】:

    标签: php regex string preg-replace logic


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 2019-04-13
      • 1970-01-01
      • 2016-07-30
      相关资源
      最近更新 更多