and don't use eregi_replace too much! 😉
it is much slower than preg_replace in most cases, preg_replace won't be case sensitive using /i at the end of the pattern;
for simple string replacements it's much faster to use str_replace, in your case strtr should be optimal, because you're walking an array.
if you used
foreach($patterns as $key => $val) {
$foo = preg_replace("/".$key."/i", "<img src='images/smiles/".$val."' border=0>\n",$foo);
}
... this would be very much slower depending on the length of the text and the number of smiley-replacements, because each loop would look up the whole text and preg_replace is always a bit slow because of it's 'intelligence'... 😉
if you really need preg_replace with smiles, don't forget to add a backslash "\" in front of each bracket "(" or ")" or "[" "]" or "{" "}" ...