note 9931 deleted from function.substr-count by nlopess
| From: | nlopess@php.net | Date: | Mon, 07 Jun 2004 09:36:44 +0000 |
| Subject: | note 9931 deleted from function.substr-count by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70505@lists.php.net to get a copy of this message | ||
Note Submitter: lordwo@wanadoo.fr
----
Instead using the precedent fonction posted by (don't remind).
$strg is the main string.
$srch is the string to count in $strg.
Note this function support when youve got the string "aah !" and you try to count
"a".
Support/Feedback : lordwo@wanadoo.fr
function strcount ($strg,$srch) {
$i = 0;
while ($i == 0) :
$n = strpos ($strg, $srch);
if($n != $false) {
$o++;
$strg = substr($strg,$n + 1);
}
if ($n == $false) {
if ( substr($strg,0,1) != $srch ) {
$i++;
}
else {
$o++;
$strg = substr($strg,$n + 1);
}
}
endwhile;
return $o;
}