Ok.. perhaps I was on the wrong course. Going in a route more simular to Nog's...
$str='"Hello, book." I like my book. I do not like "this book". Books are great.';
$arr = preg_split('#(".*?book.*?")#', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach($arr as $val){
if(!strstr($val, '"')){
$val = str_ireplace('book', '<b>book</b>', $val);
}
$newStr .= $val;
}
echo $newStr;
Output:
"Hello, book." I like my [B]book[/B]. I do not like "this book". [B]Book[/B]s are great.
If you don't want to bold any instance of the word book that has any of its letters capitalized, then simply use str_replace instead of str_ireplace.
EDIT - I am treating this like a search engine that highlights even part of words.. hence Books get the treatment.. if this is not desireable, you can simply use the following line in place of str_replace:
$val = preg_replace('#\bbook\b#', "<b>book</b>", $val);