Displaying text surrounding keywords

Hello, can anyone help me display the text surrounding keywords found within text?
A sketch of my current setup is here: http://farmville.byethost8.com/

I’m trying to get something like where, for example, if a user searches “foo”
A result’s description might read
[size=18pt]Page Name[/size]
[hr]
… bla bla bla foo bla bla bla…"

Thanks! :slight_smile:

Never mind, I found a way - here it is for anyone who might stumble upon this…

[php]
echo str_replace($KEYWORDS, $EMPHAZIZING_CODE_FOR_KEYWORDS, mb_substr($TEXT_TO_FIND_IN,stripos($TEXT_TO_FIND_IN, $KEYWORDS),CHARS_TO_SHOW));

Example:

$rep=’’ . $terms . ‘’;
$terms=ereg_replace("[^A-Za-z0-9-]", “”, $_POST[‘search’]);
$list=file_get_contents(’’);

str_replace($terms, $rep, mb_substr($list,stripos($list, $terms),170));
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service