What I need to do is convert any html entities to the actual html character. It can be in javascript or preferable php.
Here's the senario. When I save content to the database from TinyMCE it converts it to html entities for me. That's all good and great when the webpage is rendered, but when I also what to put it in a text input the html entities stick and to a normal user it looks a little wonky.
The only way I can think of doing it is have an array with the entity as the key and character as the value. When an entity is found, check t开发者_StackOverflow中文版hat array and spit out the value.
Does anyone have a better/more efficient solution, possibly using regex?
html_entity_decode sounds like it is what you are after. It isn't often that people want to take HTML input from users and then display it as text later though.
You can obviously use html_entity_decode
at the PHP level or if you're getting the data to javascript through ajax you can use unescape()
javascript function to do the same thing at the client-side
Use php function html_entity_decode
Have you tried applying html_entity_decode
to your text? Documentation here
精彩评论