PHP – Generate Automatic Smileys

December 29th, 2012 by Laeeq | No comments

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. ?>


smilies example

You can subscribe to PHPZAG.COM posts by Email


Related Topics:

  • How to Remove Leading & Trailing White Spaces with PHP
  • Parse HTML/Web Pages with PHP
  • Block Multiple IP Addresses Using PHP
  • How much memory do PHP variables use?
  • Manipulating PHP arrays: push, pop, shift, unshift


    1. No comments yet.
    1. No trackbacks yet.