I was looking for the same solution and landed here. The accepted solution does not work with non-word characters like apostrophes and accent marks and so forth. Below, find the solution that worked for me.
Here is my test sentence:
Claire’s favorite sonata for piano is Mozart’s Sonata no. 15 in C Major.
The accepted answer gave me the following results:
Array
(
[0] => Claire
[1] => ’s
[2] => favorite
[3] => sonata
[4] => for
[5] => piano
[6] => is
[7] => Mozart
[8] => ’s
[9] => Sonata
[10] => no
[11] => . 15
[12] => in
[13] => C
[14] => Major
[15] => .
)
The solution I came up with follows:
$parts = preg_split("/\s+|\b(?=[!\?\.])(?!\.\s+)/", $sentence);
It gives the following results:
Array
(
[0] => Claire’s
[1] => favorite
[2] => sonata
[3] => for
[4] => piano
[5] => is
[6] => Mozart’s
[7] => Sonata
[8] => no.
[9] => 15
[10] => in
[11] => C
[12] => Major
[13] => .
)