PHPFAN10 Posted January 23, 2011 Share Posted January 23, 2011 Hi, I have a simple smiley function below. Everything works great. Problem i am having is for (big grin) i enter and it would show a big grin smiley like it should but if it enter it will show it as it is in text. I want to make my function so that whether it would be a capital letter or not aslong as the letter matches it would still show the (big grin) smiley, at the moment it has to exactly match. The samething applies to all my smileys in function apart from Could someone edit it for me please to correct where i am going wrong? <?php # Smilies Function function smileycode($smileycode) { $input = array( '', '', '', '', '' ); $output = array( '<img src="/images/smileys/001_smile.gif" alt="" />', '<img src="/images/smileys/sad.gif" alt="" />', '<img src="/images/smileys/biggrin.gif" alt="(Big Grin)" />', '<img src="/images/smileys/ohmy.gif" alt="(OMG)" />', '<img src="/images/smileys/001_tongue.gif" alt="(Poke Tongue)" />' ); $smileyrtrn = str_replace($input, $output, $smileycode); return $smileyrtrn; } ?> Thanks PHPLOVEr Link to comment https://forums.phpfreaks.com/topic/225387-little-niggle-with-function/ Share on other sites More sharing options...
vibes Posted January 23, 2011 Share Posted January 23, 2011 hi, try the case insensitive str_ireplace() instead http://www.php.net/manual/en/function.str-ireplace.php Link to comment https://forums.phpfreaks.com/topic/225387-little-niggle-with-function/#findComment-1163912 Share on other sites More sharing options...
PHPFAN10 Posted January 23, 2011 Author Share Posted January 23, 2011 hi, try the case insensitive str_ireplace() instead http://www.php.net/manual/en/function.str-ireplace.php Thanks vibes, I forgot about the case insensitive one works lovely Cheers! Link to comment https://forums.phpfreaks.com/topic/225387-little-niggle-with-function/#findComment-1163913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.