Re: String matching for sample code doesn't work....
| From: | Scott Fletcher | Date: | Wed, 19 Nov 2003 18:28:56 +0000 |
| Subject: | Re: String matching for sample code doesn't work.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170331@lists.php.net to get a copy of this message | ||
Never mind that! It work now.... Been working on it for a few hours
though....
"Scott Fletcher" <scott@abcoa.com> wrote in message
news:20031119173857.94337.qmail@pb1.pair.com...
> Hi Everyone!
>
> I'm not really sure why does this simple script not work. When I run
> the code, the loop kept going until it timed out. I'll enclose the simple
> code here...
>
> --snip--
> $res_str = "<Dog Name>Whoof</Dog Name><![CDATA[Whose Dog is
> that??]]>";
>
> for ($i=0;$i<1000000;$i++)
> {
> if (substr($res_str, $i, 9) == "<![CDATA[")
> {
> echo "You got it!!!!";
> }
> }
> --snip--
>
> This one should work but it doesn't, but I noticed that it does work
if
> I use this instead...
>
> --snip--
> if (substr($res_str, $i, 7) == "[CDATA[")
> --snip--
>
> So, the problem had to do with either the '<' character or the '!'
> character that doesn't match. I thought maybe an escape character would
> work, like '\' but it doesn't do anything. So, anyone know how to fix
that
> problem?
>
> Thanks,
> Scott F.