note 18194 added to function.strpos

From: Date: Mon, 14 Jan 2002 08:51:40 +0000
Subject: note 18194 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-24790@lists.php.net to get a copy of this message
I'm not sure if this is common, but I'll take an example: $str="123456test7890"; If I do: for($i=0;$i<strpos($str, "te");$i++) print $str[$i]; print "Hey mon"; for($i=strpos($str,"st")+2;$i<strlen($str);$i++) print $str[$i]; on the second loop the strpos() returns something, that is not true. (pos=2 or something). Solution: Before for:s take the boundaries to variables like: $startPos=strpos($str, "te"); $endPos=strpos($str, "st")+2; anduse them in for-loops Yes, I know I can ereg("(.*)test(.*)",$str,$parm) but I just came across this... The PHP version I'm using is 4.0.4pl1 :)Mikko -- http://www.php.net/manual/en/function.strpos.php http://master.php.net/manage/user-notes.php?action=edit+18194 http://master.php.net/manage/user-notes.php?action=delete+18194 http://master.php.net/manage/user-notes.php?action=reject+18194

« previous php.notes (#24790) next »