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 .
Depending on your IDE / text editor, or how you're accessing your file (ie: ssh/ftp/etc.) You may also consider using or playing around with one of the following escape characters for newline
Rather use preg_replace for this:
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.\n
is the new line character: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".