/ Published in: PHP
This will count sentences that end in . or ? or ! and have a space after them.
Expand |
Embed | Plain Text
function countSentences($str){ } countSentences("This is a test. Hey!"); // returns 2 countSentences("What do you want?"); // returns 1 // etc.
Comments
Subscribe to comments
You need to login to post a comment.

echo countSentences("This is a test... Hey!"); // returns 3 (oops!)
Oh my! I'll work on that