Substring a text since the target founded

Posted by user580463 on Stack Overflow See other posts from Stack Overflow or by user580463
Published on 2011-11-21T17:04:11Z Indexed on 2011/11/21 17:50 UTC
Read the original article Hit count: 170

Filed under:
|

I have a search on my php page and it is ok.

With my search result, I highlighted the string target on my content.

$search_tag_text = @preg_replace("/($mysearch)/i", "<u style=\"color:red\">$1</u>", $row->txtContent);

Ok, but is it possible, after having found a string target on my content, to show 20 words before and 20 words after, instead listing all my content?

Any help will be appreciated.

© Stack Overflow or respective owner

Related posts about preg-replace

Related posts about substring