dte49889 2012-08-02 05:30
浏览 102
已采纳

如何使用PHP替换字符串中的开始和结束h1标签?

I have captured the <h1> tag and its inner contents from a webpage and I need to remove the <h1> and </h1> parts of the string. The problem is that I won't know if the tag is written as <h1> or <h1 id="something">, etc. I know I can write

$tag = str_replace("<h1>", '', $tag);
$tag = str_replace("</h1>", '', $tag); 

But how can I handle the more general case, where it may be <h1 id="something">, or something else?

  • 写回答

1条回答 默认 最新

  • dongwei8440 2012-08-02 05:33
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果