Is it possible to echo each time the loop is executed? For example:
foreach(range(1,9) as $n){ echo $n.\"\\n\"; sleep(1); }
Instead
You need to flush the php's buffer to the browser
foreach(range(1,9) as $n){ echo $n."\n"; flush(); sleep(1); }
See: http://php.net/manual/en/function.flush.php