note 100253 added to function.strpos

From: Date: Mon, 04 Oct 2010 15:50:52 +0000
Subject: note 100253 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-172943@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 96.247.122.123 ---- Manual Page -- http://www.php.net/manual/en/function.strpos.php Edit -- https://master.php.net/note/edit/100253 Del: integrated -- https://master.php.net/note/delete/100253/integrated Del: useless -- https://master.php.net/note/delete/100253/useless Del: bad code -- https://master.php.net/note/delete/100253/bad+code Del: spam -- https://master.php.net/note/delete/100253/spam Del: non-english -- https://master.php.net/note/delete/100253/non-english Del: in docs -- https://master.php.net/note/delete/100253/in+docs Del: other reasons-- https://master.php.net/note/delete/100253 Reject -- https://master.php.net/note/reject/100253 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172943) next »