note 31154 deleted from function.str-word-count by danbrown
| From: | danbrown@php.net | Date: | Fri, 31 Aug 2012 16:29:14 +0000 |
| Subject: | note 31154 deleted from function.str-word-count by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190379@lists.php.net to get a copy of this message | ||
Note Submitter: olivier at ultragreen dot net
----
I will not discuss the accuracy of this function but one of the source codes above does this.
<?php
function wrdcnt($haystack) {
$cnt = explode(" ", $haystack);
return count($cnt) - 1;
}
?>
That could be replace by
<?php
function wrdcnt($haystack) {
return substr_count($haystack,' ') + 1;
}
?>
I doubt this does need to be a function :)