Well, should have make one long string to the $res_str variable a lot
shorter.  :-)

It turned out that the for() loop isn't the slow part when you mentioned
about substr().  I tried out the while() loop and it is pretty much the same
when the loop take over 5 minutes.  So, it now seem to have to do with
substr() function.  Yea, I'm not sure what hte best substitute of it would
be.  In other branches off of this posting, someone said about using the
strpos().  I'm willing to give this a try but I have problem with this
because I have two "<!CDATA[[***]]>" tags in it and I want to use both, not
just first one.

Scott

"Chris W. Parker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Scott Fletcher <mailto:[EMAIL PROTECTED]>
    on Wednesday, November 19, 2003 1:12 PM said:

> function CBC_XML_BreakUp(&$strResponse_XML, &$strResponse_HTML)
>
> {

[snip]

Wow I didn't think you were going to post your whole program. :0

1. Are you sure the for() loop is the slow part?

2. As someone already suggested, calculating the sizeof() outside of the
loop should help a lot. Another enhancement is changing your for() to
while(). (This is a small enhancement but makes a bigger difference as
your iterations increase.)

REGULAR for() loop construct:

$iMax = 99;

for($iCnt = 0; $iCnt < $iMax; $iCnt++)
{
}

OPTIMIZED:

$iMax = 99;
$iCnt = -1;

while(++$iCnt < $iMax)
{
}

Like I said it's only slightly faster, but might make a difference
depending on your number of iterations.

3. I think what may be slowing you down is your substr() calls. Maybe
there is a substitute function that is faster? (I don't have any ideas
unfortunately.)


Let us know if you figure something out.

HTH,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to