/    Sign up×
Community /Pin to ProfileBookmark

why would it not breaK ?

I tried this to break a file function after a given time but it does not independently of the increment in time I give… How could I make it stop (or break) after 0.0005 sec ?

thanks for your help !

[code=php]<?
$n = time();
while (time() < $n+0.0005)
{
$line2s = file (“http://www.mysite.com”.$_GET[‘query2’]);
}
print_r ($line2s);
?>[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscApr 21.2007 — I don't know how to break out of a loop after a given amount of time, but I can tell you why your code isn't working ?

Your while loop tests the condition and if it returns true, then it executes the statements within it....until they are finished or it encounters a break or continue or something along those lines. At which point it will test the condition again, and do either execute the statement(s) if true, or not (if false).

You cannot stop a loop this way... the above while statement will return true the first time, execute the contained statement until it is complete, and then test the condition again....

sorry for being repetitive, but it doesn't work this way. get me?
Copy linkTweet thisAlerts:
@patimagesauthorApr 21.2007 — got you man !

thanks ! thought this could do it .... any idea ?
×

Success!

Help @patimages spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...