dongxieyou3314 2012-07-09 08:28
浏览 35
已采纳

使用preg_replace检索该省略的字符串

I need to fetch the img tag info as well (<img src="images/construction.jpg" border="0" alt="" />) what function and code amendment i need to do as this code im using is in my foreach loop as the data is iterating from the db.

My working Code---

<?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

?>
  • 写回答

1条回答 默认 最新

  • dongmeng1402 2012-07-09 08:33
    关注

    You need to use preg_match to retreive that data instead of preg_replace.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计