note 31154 modified in function.str-word-count by aidan
| From: | aidan@php.net | Date: | Sat, 26 Jun 2004 06:17:45 +0000 |
| Subject: | note 31154 modified in function.str-word-count by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71720@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.
<?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 dougbt this does need to be a function :)
--was--
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://php.net/manual/en/function.str-word-count.php