Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
195 views
Welcome To Ask or Share your Answers For Others

1 Answer

is the new line character:

$content = str_replace("</h2>
<ol>", $title, $content);

Just make sure you always use it in double quotes for PHP to recognize it as an escape sequence otherwise it will interpret it as a literal "slash" "n".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...