I have a string like this :
$string = "somehting<br><br>";
When I try str_replace() like this:
echo str_replace("<br>","<c>",$string);
The output string doesn't change at all.
What I tried:
echo mb_detect_encoding($string); // returns UTF-8
var_dump(strpos($string, "<br>")); // bool(false)
I have edited the string with html dom node class before and now I really don't know what is wrong.
I have tried to reproduce the problem on sandbox.onlinephpfunctions.com with real string and it works.
So I am unable to reproduce the problem.
So as it turns out. Your string is encoded with html-entities. So you see this by simply looking into the source code or using highlight_string($yourString) and then you will see: < instead of <.
To decode it back simply use html_entity_decode(). As example:
$string = str_replace("<br>","<c>", html_entity_decode($string));
highlight_string($string);
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