I think you misunderstood what a loop condition means. A loop runs while its condition is true, so after the loop has ended, the variables involved in the loop must be in a state such that the loop condition is false. Consider:
while ($x <> 0)
{
$x++;
}
echo $x;
Suppose the value of $x was a non-positive integer before the loop. What is the value of $x after the loop? The answer must be 0, since only when $x = 0 then ($x <> 0) is false.
Of course, in your example there are other variables at play, so the loop condition is more complex hence we cannot say if the value of $D necesarily is 0 after the loop, but we can say that at least one of these conditions is true:
1. The value of $W is equal to the value of $D
2. The value of $X is greater than 100000
3. The value of $D is equal to 0
Incidentally, I suggest using != instead of <> as it seems more common in PHP code.