How can PHP be used to create nested while loops effectively?

When creating nested while loops in PHP, it is important to maintain clarity and readability in the code. One effective way to do this is by using meaningful variable names and properly indenting the nested loops. Additionally, it is crucial to ensure that the conditions for each while loop are correctly defined to avoid infinite loops.

// Example of using nested while loops in PHP

$outerLoop = 1;

while ($outerLoop <= 3) {
    echo "Outer loop iteration: $outerLoop <br>";

    $innerLoop = 1;
    while ($innerLoop <= 2) {
        echo "Inner loop iteration: $innerLoop <br>";
        $innerLoop++;
    }

    $outerLoop++;
}