jeudi 5 novembre 2015

PHP For Doesn't Execute Properly

It seems like php is not initializing the $j variable after the first loop:

<?php
$aux=1;
for ($i=0; $i < 100; $i++) { 
    echo "<pre>I : $i</pre>";
    for ($j=$aux; $j < 10; $j++) { 
        echo "<pre>J : $j</pre>";
        if($aux % 10 === 0){
            $aux = $j;
            break;
        }
    }
}
?>

Does anyone can tell me if it is the normal behavior. I google it and everything a saw say that the first expression is aways executede in the begining of the loop.




Aucun commentaire:

Enregistrer un commentaire