为什么这些嵌套的while循环不起作用?

ali*_*iov 2 php nested while-loop

我尝试并试图让这个代码工作,并继续提出zilch.所以我决定尝试使用"for loops"而不是它首先尝试.有人能告诉我为什么这段代码不好?

<?php
$x = $y = 10;

while ($x < 100) {
    while ($y < 100) {
        $num = $x * $y;
        $numstr = strval($num);
        if ($numstr == strrev($numstr)) {
            $pals[] = $numstr;
        }
        $y++;
    }
    $x++;   
}
?>
Run Code Online (Sandbox Code Playgroud)

Mar*_*ani 10

你应该在第一次重置y = 10.

$x = 10;

while ($x < 100) {
    $y = 10;
    while ($y < 100) {
        $num = $x * $y;
        $numstr = strval($num);
        if ($numstr == strrev($numstr)) {
            $pals[] = $numstr;
        }
        $y++;
    }
    $x++;   
}
Run Code Online (Sandbox Code Playgroud)