note 31154 added to function.str-word-count
| From: | olivier at ultragreen dot net | Date: | Fri, 11 Apr 2003 11:10:44 +0000 |
| Subject: | note 31154 added to function.str-word-count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46491@lists.php.net to get a copy of this message | ||
I will not discuss the accuracy of this function but one of the source codes above does this.
function wrdcnt($haystack) {
$cnt = explode(" ", $haystack);
return count($cnt) - 1;
}
That could be replace by
function wrdcnt($haystack) {
return substr_count($haystack,' ') + 1;
}
I dougbt this does need to be a function :)
--
http://www.php.net/manual/en/function.str-word-count.php
http://master.php.net/manage/user-notes.php?action=edit+31154
http://master.php.net/manage/user-notes.php?action=delete+31154
http://master.php.net/manage/user-notes.php?action=reject+31154