any ideas why this eregi_replace isn't working? i've tried a bunch of variations and end up having it rehash the $definition with another $definition. the idea is if the word root is in $wordarray[$i] it gets highlighted with the root definition.
$rf = trim($rf);
$wordarray = split(" ", $rf);
for ($i = 1; $i <= count($wordarray)-1; $i++) {
foreach ($dictionary as $term=>$definition)
{
//if ($wordarray[$i] == $term){
//$wordarray[$i] = "<a href=\"javascript:void(0);\" onmouseover=\"return overlib('$definition');\" onmouseout=\"return nd();\" class=\"definition\">$wordarray[$i]</a>";
$wordarray[$i] = eregi_replace("$term(.*)", "<a href=\"javascript:void(0);\" onmouseover=\"return overlib('$definition');\" onmouseout=\"return nd();\" class=\"definition\">$wordarray[$i]\1</a>", $wordarray[$i]);
//}
}
}
$rf = implode(" ", $wordarray);