there's a function named set_time_limit(seconds)
but there seem to be other limiters as well, apart from php (webserver, client).
I once had to make an import script that would excerpt a 30M flat file and write its values into a database (one-time running only). I discovered that (in addition to having set the time limit as above) it's a good choice to spit out some notification line for each processed statement, so the browser is "reminded" that it's still receiving input.
better don't user proper html (< html > < head > etc), just echo, for instance, the sql statement currently processed, thus producing plaintext output. my script ran for 30 minutes. it's worth a try.