note 15364 added to function.preg-split
| From: | emilebosch at hotmail dot com | Date: | Thu, 06 Sep 2001 19:52:24 +0000 |
| Subject: | note 15364 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17739@lists.php.net to get a copy of this message | ||
hehe.. just for some friend of my i posted this thingie.. it's for counting words in a string!
:-)
<?
function cntWords($str) {
return (count(preg_split("'\s+'"," {$str} "))-2);
}
echo cntWords("This is a stupid test");
?>
Good luck people!
Greets,
Emile Bosch
http://www.php.net/manual/en/function.preg-split.php