I want to delete all occurrences of this substring from my html file:
<span style="font-size: 12pt;">BLANK PAGE</span>
I tried str_replace, thinking that would be a simple solution, but it does not work:
$html = str_replace('<span style="font-size: 12pt;">BLANK PAGE</span>', '', $html);
Any suggestions?
UPDATE: Mystery solved! Thanks to everyone for letting me know that this should work. Turns out the problem had nothing to do with str_replace! I had grabbed the html string from firebug, not realizing that firebug inserts spaces to "prettify" the html. That's why str_replace failed to find this exact pattern. I would ideally like to delete this question, since the problem ended up having nothing to do with str_replace. Is that possible?
str_replace()
returns the new version - you need to assign it back to the variable (or a new variable):
$myhtml = str_replace('<span style="font-size: 12pt;">BLANK PAGE</span>', '', $myhtml);
It should work that way. Did you perhaps forget to assign the result back to your variable?
$myhtml = str_replace('<span style="font-size: 12pt;">BLANK PAGE</span>', '', $myhtml);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With