note 32160 added to function.str-word-count

From: Date: Mon, 19 May 2003 09:55:44 +0000
Subject: note 32160 added to function.str-word-count
Groups: php.notes 
Request: Send a blank email to php-notes+get-48572@lists.php.net to get a copy of this message
if string doesn't contain the space " ", the explode method doesn't do anything, so i've wrote this and it seems works better ... i don't know about time and resource function str_incounter($match,$string) { $count_match = 0; for($i=0;$i<strlen($string);$i++) { if(strtolower(substr($string,$i,strlen($match)))==strtolower($match)) { $count_match++; } } return $count_match; } // example $string = "something:something!!something"; $count_some = str_incounter("something",$string); // will return 3 ---- Manual Page -- http://www.php.net/manual/en/function.str-word-count.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32160 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32160&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32160&report=yes

« previous php.notes (#48572) next »