note 99713 modified in function.strpos by danbrown
| From: | danbrown@php.net | Date: | Wed, 01 Sep 2010 04:20:41 +0000 |
| Subject: | note 99713 modified in function.strpos by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172226@lists.php.net to get a copy of this message | ||
Here is my simple but useful function for counting the number of occurrences of the needle into the
stack
<?php
function searchOccNum($needle, $stack){
$offset = 0;
$found = 0;
if(strpos($pm, $open_link) === false)
return 0;
else{
while(!(strpos($stack, $needle, $offset) === false)){
$found++;
$offset = strpos($pm, $open_link, $offset)+1;
}
return "found: ".$found." times";
}
}
?>
--was--
Here is my simple but useful function for counting the number of occurrences of the needle into the
stack
function searchOccNum($needle, $stack){
$offset = 0;
$found = 0;
if(strpos($pm, $open_link) === false)
return 0;
else{
while(!(strpos($stack, $needle, $offset) === false)){
$found++;
$offset = strpos($pm, $open_link, $offset)+1;
}
return "found: ".$found." times";
}
}
http://php.net/manual/en/function.strpos.php