Code:
<?php /** * @author Zangz * @copyright 2009 */ function Smiles($text) { $path = "http://localhost/smilies/smilies/"; $arr = array( ":D" => $path. "biggrin.gif", ":-/" => $path. "confused.gif", "B-)" => $path. "cool.gif", ":-S" => $path. "worried.gif", ":-)" => $path. "happy.gif", ":(" => $path. "sad.gif", ";)" => $path. "winking.gif", ">:D<" => $path. "bighug.gif", ":x" => $path. "lovestuck.gif", ":'>" => $path. "blushing.gif", ":P" => $path. "tongue.gif", ":-*" => $path. "kiss.gif", "=((" => $path. "brokenheart.gif", ":-0" => $path. "surprise.gif", "X(" => $path. "angry.gif", ":>" => $path. "smug.gif", "#:-S" => $path. "whew.gif", ">:)" => $path. "devil.gif", ":((" => $path. "crying.gif", ":))" => $path. "laughing.gif", ":|" => $path. "straightface.gif", ); // http://messenger.yahoo.com/features/emoticons/ foreach ($arr as $smile => $paths) { $text = str_ireplace($smile, '<img src="'.$paths.'"align = middle" />', $text); } return $text; } $txt = "test :D test"; //example text echo Smiles($txt); ?>
Comment