Nazariy
Nazariy

Reputation: 6088

How to select portion of text like stackoverflow search result do?

I'm looking for efficient and fast php solution, that can select portion of text from document and slice it based on keywords without loosing meaning of content similar as stack overflow search engine do.

I found one similar question for C# but without any examples.

How would you implement such functionality in PHP?

Upvotes: 1

Views: 272

Answers (1)

trinth
trinth

Reputation: 6047

I know this question is old but I hate seeing questions like this go unanswered. Anyway, you need to use a full-text search engine like Sphinx Search. They have a PHP API with the necessary built-in function to automatically markup the selected text. Look up BuildExcerpts() in their API.

I only have experience with Sphinx, however, I am willing to be other Full text engines have this functionality built in as well. The keyword you're looking for is "excerpts".

Upvotes: 1

Related Questions