PHP – Generate Automatic Smileys

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.

  1. <?php
  2. $texte=‘A text message with a smiley :-)’;
  3. echo str_replace(‘:-)’,‘<img src=”images/psmilies.png”>’,$texte);
  4. ?>

Output:

smilies example

Laeeq

A web developer who has a love for creativity and enjoys experimenting with various techniques in both web design and development. If you would like to be kept up to date with our posts, you can follow us on Twitter, or even by subscribing to our RSS Feed.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera