I have found a similar thread already where I got:
$sentence = preg_replace('/(.*?[?!.](?=\s|$)).*/', '\\1', $string);
This doesn't seem to work in my function though:
<?function first_sentence($content) {
$content = html_entity_decode(strip_tags($content));
$content = preg_replace('/(.*?[?!.](?=\s|$)).*/', '\\1', $content);
return $content;
}?>
It seems to be not taking into account the first sentence when a sentence ends as the end of a paragraph. Any ideas?
Here's correct syntax, sorry for my first response:
In case you need n number of sentences, you can use the following code. I adapted code from: https://stackoverflow.com/a/22337095 & https://stackoverflow.com/a/10494335