Search code examples
phpemoticonschatroom

Allow select special characters


Hi I am using the htmlentities() PHP function for a chat room to prevent HTML being echo'd out into the chat.

Basically I want to allow this '<3' which PHP will replace with the Heart emoticon but due to the '<' symbol, the htmlentities() function is thinking it is HTML so it just comes out as plain text on the site like this '<3' and not the heart emoticon.

How can I allow users to type '<3' and it come out as a heart?


Solution

  • Use str_replace("&lt;3","<3", $msg['message_text']); to replace the '<3' with a heart