Help understanding what a while loop is doing


#1


When I change while ($i == 100) to any integer - even one outside of the rand() range, or when I change the comparison operator to ===, or a few other operators, the while echo always executes. When while ($i===100) the echo $i output in the while clause is never identical to 100. I don't understand this behavior. Could someone help me understand what is happening in this loop?

<?php
        //write your do-while loop below
        $i=rand(0,500);
        do {
            echo "eat ";
        }
        while ($i == 100);
        
        echo " " . $i . " pickles";  
        
    ?>


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.