I want to get some sentences from a text.
Sample text is following,
Gryphon interrupted in a low voice. 'Not at all,' said the Dodo, pointing to the confused clamour of the wood--(she considered him to you, Though.Gryphon interrupted in a low voice. 'Not at all,' said the Dodo, pointing to the confused clamour of the wood--(she considered him to you, Though.Gryphon interrupted in a low voice. 'Not at all,' said the Dodo, pointing to the confused clamour of the wood--(she considered him to you, Though.
What I've done so far is I'm able to get 30 words from a large text but at the end, I've got an incomplete sentence and I want to remove such sentence.
Here is the function to get 30 words,
/**
* @param $sentence
* @param int $count
* @return mixed
*/
function get_words($sentence, $count = 30) {
preg_match("/(?:\w+(?:\W+|$)){0,$count}/", $sentence, $matches);
return $matches[0];
}
I've used above function from the question below
How to select first 10 words of a sentence?
When I pass above text to the function I've got output like this,
Gryphon interrupted in a low voice. 'Not at all,' said the Dodo, pointing to the confused clamour of the wood--(she considered him to you, Though.Gryphon interrupted in a
Here the last sentence is incomplete and I don't want such in my output.
Is there any way to achieve this?
I'm working with PHP and Laravel any kind of help and suggestions are appreciated.