0 jagdish posted how to delay execution in php ? foreach($code as $c){ // run some code // delay execution for some second before continuing to execution } I want to put some delay code in PHP. Edit Question
1 sandip answered Jan 20 '22 00:00 use sleep() function, which can be used to delay in execution in PHP. foreach( .. ){ // sleep for 5 seconds sleep(5); } sleep(5), it program will sleep for 5 seconds in every iteration of foreach loop Edit Answer
0 pratik answered Jan 20 '22 00:00 you can delay execution in PHP for nanosecond as well with time_nanosleep() function . time_nanosleep — Delay for a number of seconds and nanosecondstime_nanosleep(int $seconds, int $nanoseconds) : you can delay execution with second and nanoseconds combination . time_nanosleep(0,5) -- will delay execution for 5 nanoseconds . Edit Answer