note 100253 deleted from function.strpos by danbrown
| From: | danbrown@php.net | Date: | Mon, 04 Oct 2010 15:52:43 +0000 |
| Subject: | note 100253 deleted from function.strpos by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172944@lists.php.net to get a copy of this message | ||
Note Submitter: David Kenneally
----
The occurrence counting function is handy, but I think the variable names were slightly off. Here is
a modified version:
function searchOccNum($needle, $stack){
$offset = 0;
$found = 0;
if(stripos($needle, $stack) === false)
return 0;
else{
while(!(stripos($stack, $needle, $offset) === false)){
$found++;
$offset = stripos($needle, $stack, $offset)+1;
}
return "found: ".$found." times";
}
}
I'm using this to count unclosed div's in user supplied html, so that they can't
destroy the page layout.