Well, in this case, I would personally resort to exploding and other string specific functionality. Here is what I came up with:
Example:
$keyword = 'contract';
$str = <<<DATA
SUNRISE, Fla. -- A third-period comeback was the perfect way to cap a great day for Daniel Alfredsson and the Ottawa Senators.
Hours after captain Daniel Alfredsson signed a four-year contract extension, Dany Heatley and Chris Kelly scored to help the Senators beat Florida 2-1.
"It makes a big difference," Alfredsson said. "I'm really going to enjoy dinner tonight, I can tell you that, coming back the way we did."
DATA;
$array = explode($keyword, $str);
if(count($array) > 1 && strlen($array[0]) > 74 && strlen($array[1]) > 74){
$finalString = substr($array[0], -75) . '<span style=\'color: #FE0606;\'><strong>' . $keyword . '</strong></span>' . substr($array[1], 0, 74);
echo $finalString;
} else {
echo 'Error.. not enough characters involved...';
}
Ouput:
Ottawa Senators. Hours after captain Daniel Alfredsson signed a four-year contract extension, Dany Heatley and Chris Kelly scored to help the Senators beat
Of course, here's the crux. Depending on which key word you use, and how long the paragraph, you may end up with more than two arrays from the explode function.. so the question becomes.. which two arrays do you choose?
Case in point... suppose you change the value of $keyword to 'and'.... there are more than two arrays.. so which ones do you use? If the key words are not common and are very specific within a paragraph, the solution should work well.. otherwise, it gets a little hazy...
Cheers,
NRG