I am writing a script that gets an eight digit number then reads it out loud. I want a delay of two seconds between the numbers as they are being read out. The problem is that even after setting the delay with sleep(), all my numbers are read out at once which leads to a summon-like audio that is getting me closer to being the antichrist with every debug. Here is my code. How do i get my loop to execute so that the numbers are read as e.g 2 .... 1 .... 3 .... 4 .... (where .... = 2 seconds.)
for($counter=0; $counter<count($dbId); $counter++)
{
$fileName = array_search($dbId[$counter], $letterArray);
echo "<audio src='../resources/audio/mp3/'.$fileName.'.mp3' autoplay></audio>";
echo time() . "<br />";
sleep(2);
}