php - str_replace() doesn't work as expected -


i have string :

$string = "somehting<br><br>"; 

when try str_replace() this:

echo str_replace("<br>","<c>",$string); 

the output string doesn't change @ all.

what tried:

echo mb_detect_encoding($string); // returns utf-8 var_dump(strpos($string, "<br>")); // bool(false) 

i have edited string html dom node class before , don't know wrong.

i have tried reproduce problem on sandbox.onlinephpfunctions.com real string , works.

so unable reproduce problem.

so turns out. string encoded html-entities. see looking source code or using highlight_string($yourstring) , see: &lt; instead of <.

to decode use html_entity_decode(). example:

$string = str_replace("<br>","<c>", html_entity_decode($string)); highlight_string($string); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -