I'm trying to write a simple function that truncates a string down to its first three sentences. I've written the following and it works well:

```
function getExcerpt($string) {
    if($string != "") {
        $strArray = explode('. ', $string);
        return $strArray[0].'. '.$strArray[1].'. '.$strArray[2].'. ';
    }
    return $string;
}

```

The problem is that it fails when the first few sentences end in "?" or "!".

So, for example, the following text is considered **one** sentence, instead of **three**:

> 
> What is intelligence? How do we define intelligence? This paper seeks to answer that question.
> 
> 
> 

`explode` is no use, so I thought I'd use `preg_split` -- but the problem is that I need to replace the "?"s and "!"s in their right places.

What's a simple way to solve this problem? Is there a handy PHP "sentence" function I don't know about?