Thanks again, Hayley, for your input.
I have included the following code to show the success so far, related back to my initial question.
<?
$tempstr = "aaa bbb eeeeee ddd eeeCCCeee fff ggg eCCCeeeee";
$srchword = "eeeeee";
$somecode = "CCC"; // variable, any code, in reality is an html-like code
$boldon = "BB"; // instead of html codes--just for this test
$boldoff = "bb"; // instead of html codes--just for this test
$count = strlen($srchword)-1;
echo $tempstr . "<br>";
$tempstr = preg_replace("/(\w*". preg_replace("/(.)/","\\1[" . $somecode . "]*",$srchword,$count) ."\w*)/i",$boldon . "\\1" . $boldoff,$tempstr);
echo $tempstr;
?>
Curious about 2 things.
Is this embedded preg_replace the best solution? Couldn't think of a better one.
$somecode will really be an html-like code with brackets and an undetermined length.
I had intended to use something like [<*.?>] but was unable to get that to work--any ideas why? (for this test, I used CCC to avoid any display problems.)
Thanks for all your help!
Dan