I would like to set a timeout on an execution in php. I want to loop through and I want to cut at 5 for example because of the execution time I set.
ini_set('max_execution_time',2);
for ($i=0;$i<10;$i++){
echo time();
echo ' i:'.$i;
echo "\n";
echo "\n";
}
would like to give it a limit.
Using
ini_set('max_execution_time',2);would affect the whole PHP script and may causeYou can simple add your time calculation to your
forloop instead;Output