Posted By

gnetsystems on 11/14/09


Tagged

emoticons


Versions (?)

Emoticons :) to Image


 / Published in: PHP
 

  1. function smiley($str){
  2. //smileys to check for
  3. $smiles=array(
  4. ":)",":-)",":D",":-D",";)",";-)",":O",
  5. ":-O",":P",":-P","w00t","8)","8-)",":S",
  6. ":s","\:\(","\;\(","\|\)",":@"
  7. );
  8. // replace with emoticons
  9. $replacements=array(
  10. "<img src="http//yourwebsite.com/image/smile.gif" width="20" height="20" title="happy smiley" />",
  11. "<img src="http//yourwebsite.com/image/smile.gif" width="20" height="20" title="happy smiley" />",
  12. "<img src="http//yourwebsite.com/image/biggrin.gif" width="20" height="20" title="big grin smiley" />",
  13. "<img src="http//yourwebsite.com/image/biggrin.gif" width="20" height="20" title="big grin smiley" />",
  14. "<img src="http//yourwebsite.com/image/wink.gif" width="20" height="20" title="winking smiley" />",
  15. "<img src="http//yourwebsite.com/image/wink.gif" width="20" height="20" title="winking smiley" />",
  16. "<img src="http//yourwebsite.com/image/ohmy.gif" width="20" height="20" title="oh my smiley" />",
  17. "<img src="http//yourwebsite.com/image/ohmy.gif" width="20" height="20" title="oh my smiley" />",
  18. "<img src="http//yourwebsite.com/image/tongue.gif" width="20" height="20" title="tongue smiley" />",
  19. "<img src="http//yourwebsite.com/image/tongue.gif" width="20" height="20" title="tongue smiley" />",
  20. "<img src="http//yourwebsite.com/image/w00t.gif" width="20" height="20" title="w00t smiley" />",
  21. "<img src="http//yourwebsite.com/image/roll.gif" width="20" height="20" title="roll eyes smiley" />",
  22. "<img src="http//yourwebsite.com/image/roll.gif" width="20" height="20" title="roll eyes smiley" />",
  23. "<img src="http//yourwebsite.com/image/huh.gif" width="20" height="20" title="huh smiley" />",
  24. "<img src="http//yourwebsite.com/image/huh.gif" width="20" height="20" title="huh smiley" />",
  25. "<img src="http//yourwebsite.com/image/sad.gif" width="20" height="20" title="sad smiley" />",
  26. "<img src="http//yourwebsite.com/image/crying.gif" width="20" height="20" title="crying smiley" />",
  27. "<img src="http//yourwebsite.com/image/sleep.gif" width="20" height="20" title="sleep smiley" />",
  28. "<img src="http//yourwebsite.com/image/mad.gif" width="20" height="20" title="mad smiley" />",
  29. );
  30. for($i=0;$i < sizeof($smiles);$i++){
  31. $str=eregi_replace($smiles[$i], $replacements[$i], strtolower($str));
  32. }
  33. return $str;
  34. }

Report this snippet  

You need to login to post a comment.