PHP Code:
function affiliateparse($text) {
$affiliate_code1 = "[ URL=http://www.google.com ][ img]http://www.site.com/yourimage[ /img][ /URL ]";
$text = stri_replace("Google",$affiliate_code1,$text);
$affiliate_code2 = "[ URL=http://www.google.com ][ img]http://www.site.com/yourimage[ /img][ /URL ]";
$text = stri_replace("Google",$affiliate_code2,$text);
return $text;
}