title: How can I split a PHP script that takes a long time to run into smaller chunks?
body: <p>I have a PHP script that initialises an image gallery. It loops through all images, checks if they are thumbnailed and watermarks them.</p>
  
  <p>My shared hosting account only lets me have 30 seconds of execution per script, as set in the php.ini settings. I can't change that.</p>
  
  <p>What can I do to get round this? Currently I refresh the page after every 5 images, this prevents the script timing out, but the browser recognises that the script won't complete and gives an error. That's ok, but it's not really user friendly.</p>
  
  <p>Any suggestions?</p>