lundi 29 août 2016

Counting contractions as 2 words instead of 1 in str_word_count()

I'm trying to get the word counts of a string, but I want to count contractions as 2 words instead of 1. Is there a way to do this with str_word_count()?

$string = "i'm not";
$count = str_word_count($string);

echo $count;

Result:

2

Want Result:

3

Aucun commentaire:

Enregistrer un commentaire