Jump to content

Replace certain keywords (array) in a string


maxudaskin

Recommended Posts

// 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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.