Is there a way to timeout a function? I have 10 minutes to perform a job. The job includes a for loop, here is an example:
PHP is single threaded... you have to use your OS's ability to fork another process.
The only way I know how to do this is with the exec command to fork off another full process. Put the stuff you want timed in a separate script, call exec on the script, then immediately sleep for 10 min. If at 10 min the process is still running kill it. (you should have it's PID by making the command run the new php code in the background, getting it via command line and returning it from the exec command).