Lessee if you can get away with this:
$smilies=array(
':)' => '01.gif',
':(' => '02.gif',
':D' => '03.gif'
);
$string="I'm :), I'm, :(, and now I'm :D";
$search=array_keys($smilies);
$replace=array_values($smilies);
foreach($replace as $k=>$v)
{ $replace[$k]="<img src='$v' />";
}
$string=str_replace($search, $replace, $string);
echo $string;
I can ditch the loop:
$smilies=array(
':)' => "<img src='01.gif' />",
':(' => "<img src='02.gif' />",
':D' => "<img src='03.gif' />"
);
$string="I'm :), I'm, :(, and now I'm :D";
$string=str_replace(array_keys($smilies), $array_values($smilies), $string);
echo $string;