$findwords=array(0 => '{getmicrostats}', 1 => '{bbusername}'); $replacewords=array(0 => $microstats, 1 => "$bbuserinfo[username]<!-- auto name hack -->"); $i=1; while ($var=$DB_site->fetch_array($vars) and $i++) { if ($var['findword']!='') { $findwords[$i]=$var['findword']; $replacewords[$i]=$var['replaceword']; } } $newtext=str_replace($findwords,$replacewords,$newtext);