Well,
$str="The quick brown fox jumped over the lazy dog"
$margin=5;
$str=substr($str,strpos($str, "fox")-$margin,$margin*2+3);
echo "$str";
This is not a perfect script, and you'll have to do error checking to make sure that 2nd argument in substring will not be less then 0.
Return value should be "rown fox jump", 5 characters from the left and five from the right.
Di