html标签之间的preg_replace()文本,同时保留标签

时间:2019-01-27 23:58:08

标签: php preg-replace

下面的代码在p个html标签之间找到文本,但是我该怎么办?

  1. 回显新字符串,但保留标签而不是删除标签?
  2. 使preg规则在所有html标记之间找到文本,而不仅仅是p?
$text = "<p>old_string</p>";
echo preg_replace("#\<p\>(.+?)\<\/p\>#s","new_string", $text);

预先感谢

0 个答案:

没有答案
相关问题