note 17261 deleted from function.strpos by jimw

From: Date: Fri, 14 Dec 2001 20:08:07 +0000
Subject: note 17261 deleted from function.strpos by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22704@lists.php.net to get a copy of this message
To: clambert@gamespy.com After trying your routine, I realised that it wouldn't work either. First of all, it doesn't take into account the particularities of strpos and will return "1" regardless of wherther or not the string was found. Plus, if your needle is larger than the haystack, you will get an offset error. This one is tested, try it if you like. ($input like $needle, $search like $haystack) function find_string ($input, $search) { while (is_integer($offset=strpos($search,$input,$offset))) $offset+=strlen($input); $found++;} return $found; } ---------- Mickael Nadeau, President Pure Media Productions (418) 527-2155 ---------- admin@puremedia.ca http://www.puremedia.ca/ ----------

« previous php.notes (#22704) next »