On 10 September 2003 12:14, zavaboy contributed these pearls of wisdom:

> if I wait untill $sDate is zero, it'll be in 2000.
> I have $Date based on the current date, like to day is: 03252
> 03 is the year 252 is the day of the year.

So for goodness' sake just choose a sensible value to limit the loop -- I
was just taking a stab in the dark from your mention of max 31 days'
difference to guess it was a day-number within a month, and hence my
assumption that only +ve values would be valid.

You really haven't given us very much to go on here -- it might be easier to
suggest a solution if you told us more about what *exactly* it is you're
trying to do.  And a little bit more of your *actual* code (not "something
like") might help things along, too.
> 
> "Mike Ford" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> On 10 September 2003 11:26, zavaboy contributed these pearls
>> of wisdom: 
>> 
>>> // Ok, I have a loop:
>>> for ($i = $Date; $i >= $sDate; $i--)
>>> 
>>> // Somthing like this is inside the loop:
>>> if ($Exists)
>>>  echo "Something here.";
>>> else
>>>  $sDate--;
>>> 
>>> I have it check if it exists, if it doesn't, then it reduces
>>> $sDate by 1. $sDate is initially 3 to 31 days less than
>>> $Date. By reducing $sDate by 1, it keeps looking, what if
>>> there are no more? It keeps going until I reach 30 seconds,
>>> how can I set a time limit?
>> 
>> No need to set a time limit for this -- just set a limit on
>> how far $sDate can be decremented.  Presumably only positive
>> values are invalid, so just stop the loop when $sDate goes
>> <=0 -- either 
>> 
>>     for ($i = $Date; $i >= $sDate && $sDate > 0; $i--)
>> 
>> or something like:
>> 
>>     for ($i = $Date; $i >= $sDate; $i--):
>> 
>>       if ($Exists):
>>         echo "Something here.";
>>       else:
>>         $sDate--;
>>         if ($sDate<=0):
>>           // do any necessary tidying up here -- e.g. set a
>>           // flag to say the loop was exited via the side door
>>           break;   // escape from the for loop
>>         endif;
>>       endif;
>> 
>>     endfor;
>>     // break escapes to here
>> 
>> Cheers!
>> 
>> Mike

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211

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

Reply via email to