更新时间:2022-10-23 10:29:19
而是使用 preg_replace 为此:
preg_replace("/[\s]*/", $title, $content);
不管你怎么做,它都没有真正的意义.<h2>
已启动,但是您删除了该结束标记和 <ol>
的开始标记,我假设它们也将具有结束标记?无论如何,您的输出似乎都会出错.
On a html page I have this.
</h2>
<ol>
The page is contained in a variable called $content. I want to replace this with something else but the code doesn't work.
$content = str_replace("</h2><ol>", $title, $content);
What should i put there instead of .
Rather use preg_replace for this:
preg_replace("/<\/h2>[\s]*<ol>/", $title, $content);
Regardless of how you do it, it doesn't really make sense. An <h2>
is started, but you remove that closing tag and the starting tag for the <ol>
, which will also have a closing tag I assume? Seems like your output is going to be wrong regardless.