dimanche 20 mai 2018

While Loop with multiple conditions in PHP

Generating a Random number between 0 & 3 in PHP with multiple conditions.

<?php
    $answer_ll = 1;
    $ll_50_rand_1 = 2;
    $ll_50_rand_2 = $answer_ll;
    while(($ll_50_rand_2 == $answer_ll) && ($ll_50_rand_2 == $ll_50_rand_1)){
    $ll_50_rand_2 = rand(0,3);
    }
echo $ll_50_rand_2;?>

I tried above code, but the randomly generated number is repeating either with $answer_ll or with $ll_50_rand_1.




Aucun commentaire:

Enregistrer un commentaire