Re: strpos() act funny when searching for "]]>"....

From: Date: Fri, 21 Nov 2003 16:17:37 +0000
Subject: Re: strpos() act funny when searching for "]]>"....
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-170581@lists.php.net to get a copy of this message
Um, it seem to work. That's weird. Should have check for the string length first, so I wasn't looking at the same problem. So, I did further debugging and I'm going to post the script here. Still don't know what is the problem here... --snip-- $XML_Start = (strpos($res_str,"<![CDATA[")+9); $HTML_Start = (strpos($res_str,"<![CDATA[",$XML_Start)+9); $HTML_End = strpos($res_str,"]]>",$HTML_Start); $XML_End = strpos($res_str,"]]>",$HTML_End); echo $XML_Start." ***XML Start<br>"; echo $XML_End." ***XML End<br><br>"; echo $HTML_Start." ***HTML Start<br>"; echo $HTML_End." ***HTML End<br>"; echo strlen($res_str); --snip-- The response I got here is... --snip-- 319 ***XML Start 119843 ***XML End 25650 ***HTML Start 119843 ***HTML End 120015 --snip-- As we see, the number for $XML_End and $HTML_End are the same which is not correct because there are two seperate "]]>" near the end of hte string. So, I still don't know what hte problem is... Scott F. "Curt Zirzow" <php-general@zirzow.dyndns.org> wrote in message news:20031121160303.GD42976@bagend.shire... > * Thus wrote Scott Fletcher (scott@abcoa.com): > > strpos() is acting a little bit funny. When I do this... > > > > --snip-- > > $a = strpos($data,"]]>"); > > --snip-- > > > > Problem is there are "]]>" characters in the $data string and it just > > doesn't see it. Anyone know why and what is the workaround to it? > > It works perfectly fine: > > $data = 'asdf ]]> asdf'; > $a = strpos($data,"]]>"); > print $a; //output: 5 > > > Curt > -- > "My PHP key is worn out" > > PHP List stats since 1997: > http://zirzow.dyndns.org/html/mlists/

« previous php.general (#170581) next »