<?php
// # chars before and after search string
$precede = 10;
$postcede = 4;
$str = "The quick brown fox jumped over the lazy dog";
$srch = "fox";
$temp = stristr($str,$srch);
$pos = strlen($str)-strlen($temp);
echo substr($str, ($pos - $precede), (($pos + strlen($srch)) + $postcede));
?>
For further details regarding any sort of string manipulations you should really read the String Functions section of the manual.
-geoff