maxudaskin Posted March 8, 2008 Share Posted March 8, 2008 Is it possible to 'filter' a string using an array of what I called shortcuts and image locations and have the location replace the shortcut (if found)... For example; "Hi! : )" would show "Hi! ". Link to comment https://forums.phpfreaks.com/topic/95021-replace-certain-keywords-array-in-a-string/ Share on other sites More sharing options...
peranha Posted March 8, 2008 Share Posted March 8, 2008 // Smilies Replace Code. $smiles = array("D:(","D:D","0:)","|","","|","","","","","","","","???","","",":-X",":-U","",":-(","^-^","00","P)","P:O"); $replacements = array('<img src=smilies/yellow/angry.gif>','<img src=smilies/yellow/evil.gif>','<img src=smilies/yellow/angel.gif>','<img src=smilies/yellow/smile.gif>','<img src=smilies/yellow/rolleyes.gif>','<img src=smilies/yellow/razz.gif>','<img src=smilies/yellow/sad.gif>','<img src=smilies/yellow/smiley.gif>','<img src=smilies/yellow/wink.gif>','<img src=smilies/yellow/cheesy.gif>','<img src=smilies/yellow/grin.gif>','<img src=smilies/yellow/shocked.gif>','<img src=smilies/yellow/cool.gif>','<img src=smilies/yellow/huh.gif>','<img src=smilies/yellow/tongue.gif>','<img src=smilies/yellow/embarrassed.gif>','<img src=smilies/yellow/lipsrsealed.gif>','<img src=smilies/yellow/undecided.gif>','<img src=smilies/yellow/kiss.gif>','<img src=smilies/yellow/cry.gif>','<img src=smilies/yellow/azn.gif>','<img src=smilies/yellow/afro.gif>','<img src=smilies/yellow/eyepatch.gif>','<img src=smilies/yellow/police.gif>'); That is what I use and call it like this $string = str_replace($smiles,$replacements,$string); Link to comment https://forums.phpfreaks.com/topic/95021-replace-certain-keywords-array-in-a-string/#findComment-486723 Share on other sites More sharing options...
maxudaskin Posted March 8, 2008 Author Share Posted March 8, 2008 Where'd you get your smilies from? Link to comment https://forums.phpfreaks.com/topic/95021-replace-certain-keywords-array-in-a-string/#findComment-486725 Share on other sites More sharing options...
peranha Posted March 8, 2008 Share Posted March 8, 2008 All over the net, just do a google search. Link to comment https://forums.phpfreaks.com/topic/95021-replace-certain-keywords-array-in-a-string/#findComment-486727 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.