PHP Snippets

Name:Replace Smiley
Description: This function will replace smiley text (":)",":D", etc...) with your smiley image.

Code below...
> <?php

  
//Change the image source from the function to match your smileys image directory.

  //Note: This is case sensitive so if you echo ":P" it would be different from ":p" and so on...

 
function smiley($msg) {
     
//Just keep repeating the variable for all your smileys.
      
$message ereg_replace("=)","<img src=./smile.gif alt=\"=)\" />"$message);
      
$message ereg_replace(":D","<img src=./laugh.gif alt=\":D\" />"$message);
      
$message ereg_replace(":p","<img src=./tongue.gif alt=\":p\" />"$message);
      return 
$msg;
}

 
//Here's an example
 
$message "Hi =) Hello :D Heheh :p";
 echo 
smiley($message);

 
//It's up to you to expand it and find a good use to it. ;)

?>

« Back to PHP Snippets

Home | Site Map | Privacy Policy | Advertising | Contact Us
Copyright © 2006-2014 r2xDesign.net - All Rights Reserved.
eXTReMe Tracker