I need to create a cycle to end when it is longer than 20 seconds. I have tried the following code but it's not working, running forever.
EDIT: For simple code it will stop fine, but using the include_once and include the external files keep running even after the 20 seconds expire
bot.php
$starttime = time();
while (time() - $starttime < 20) {
include_once 'onefile.php';
include 'somefile.php';
include 'somefile2.php';
}
EDIT 2:
With Josh Trii Johnston's answer the proccess is really stopped if not concluded within X seconds. The problem now is that there is another requisit on my case.. The sample provided above does not run alone. It is also included on another loop file like this:
master.php
<?php
while (1) {
include 'bot.php';
sleep(60);
}
As you can see it is running on a infinite loop and what I want is not stop the entire loop but only "break" the bot.php loop, keeping the main while(1) loop active. With the provided solution it exits all the loops and the process is terminated.