Stupid really quick PHP question

Soldato
Joined
12 Jan 2004
Posts
3,172
Location
Brighton
I have a "marked up document" containing pure text and HTML. I want a PHP function to strip out all of the weird characters (like +-& etc) and leave the HTML as it is :

echo htmlspecialchars_decode(htmlentities(implode('', file("articles/text.txt"))));

That should :

1) Convert all weird chars into their HTML entities " etc
2) Convert back all the HTML based ones into pure html.
3) Echo (dump) the text into the page.

So why do I still get weird chars?
 
htmlentities will be converting & to &, - to ‐ and your + to something else that I'm not aware of. do a str_replace on them:

str_replace(array('&','‐','+'),'',$data);

(+ probably won't work!!)
 
Back
Top Bottom