'How to out of while and for loop combined

I am trying to write a code that is capturing number 3. using while loop as the condition, so that the for statement will be the evaluation condition of $x, of the while loop statement, and by the same time, using if statement to evaluate the value of $x=3 and so it can echo 'three..'; . please enlighten me. thank you

<?php
$x = 0;
$y = 5;

while ($x <= $y) {
    for ($z = 0; $z < 3; $z++) {
        if ($x = 3) {
            echo 'three..' . "\n";
        }
    }
    $y++;
}


Solution 1:[1]

<?php
$x = 0;
$y = 5;

while ($x <= $y) {
    for ($z = 0; $z < 3; $z++) {
        echo $z;
    }
        if ($x == 3) {
            echo 'three..' . "\n";
        }
    $x++;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lordroy