note 18194 deleted from function.strpos by tularis

From: Date: Wed, 22 Aug 2007 13:26:00 +0000
Subject: note 18194 deleted from function.strpos by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-129699@lists.php.net to get a copy of this message
Note Submitter: maharj at DONTSPAMutu dot fi ---- 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

« previous php.notes (#129699) next »