We are very much familiar with smileys on Gmail and Facebook chat. We often express our emotions by pressing shift-colon and shift-backquote like “:)” during chat with our friends which displays a smiley images in place of characters. Below is complete PHP example code which allows you to automatically replace a smiley symbol character by a smiley image.
- $texte=‘A text message with a smiley :-)’;
- echo str_replace(‘:-)’,‘<img src=”images/psmilies.png”>’,$texte);