I've got a string, that has some data returned form a form.
for example's sake:
The rabbit's going to have a higher # of children because they are known for reproducing at a rapid rate > that of humans, which spend years finding a mate. And many times greater than ^Nerds^ who never seem to get laid, or ^geeks^ who... well, you know.
<br>
In summary, rabbits & geeks can coexist&nb sp; on this planet.
A few things here:
Note the > Also note the <br> Can't turn <br> into an html entity, or it won't be a html element anymore.
same with the & in "rabbits and geeks" should be &
BUT...
&nb sp; should be left alone because it's already an entity.
So my question to the PHP programmers much wiser than me, is how do I turn necessary chracters into the appropriate HTML entities, without making mistakes?
There quite a few to deal with:
http://www.w3schools.com/html/html_entitiesref.asp
So what's the best way to htmlize a string? Without breaking HTML that a user might insert.
Edit; &nb sp; has a space to prevent this very issue