I have 2 arrays and would like to print to screen after each iteration of the nested loop.
$array1 = array('1','2','3','4','5');
$array2 = array('a','b','c','d','e');
if (ob_get_level() == 0) ob_start();
foreach($array1 as $number){
foreach($array2 as $letter){
echo $number." - ".$letter."<br>";
sleep(2);
ob_flush();
flush();
}
}
In the above code, I would expect it would print "1 - a" then wait 2 seconds, then print "1 - b", wait 2 seconds, and so on. whats happening now, is it just prints it all at the end, so i have to wait the total time to see results.
where would i use the ob_start / ob_flush functions to get it to print after each iteration inside array2? i have tried everywhere