note 9931 added to substr_count
| From: | lordwo at wanadoo dot fr | Date: | Sat, 02 Dec 2000 11:59:07 +0000 |
| Subject: | note 9931 added to substr_count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8342@lists.php.net to get a copy of this message | ||
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;
}
http://www.php.net/manual/function.substr-count.php