I have the following code in which I am using a loop inside a loop to create a PHP array:
$result= mysqli_query($myqueri1);
while($row = mysqli_fetch_assoc($result))
{
$result1=mysqli_query($myqueri2); //This query utilizes a variable obtained from the outer loop. So this cant be written outside the loop.
while($row = mysqli_fetch_assoc($result))
{
//Operations
}
}
The two arrays contain almost 50k rows. And they are indexed.
However, I am more concerned about the optimization issue. If I store all the results of loop 1 into a PHP array and then iterate through it, does it make any difference? Or is using while($row = mysqli_fetch_assoc($result))
same as going through a common PHP loop? Which is more optimized?