php - How to do the same operation until it reaches one condition -


how same operation until reaches 1 condition? example:

<?php $n = rand(5,157); if ($n=='63'){ echo 'ok'; } else { //* random, until rand () give 63 *// } ?> 

how can fix this? in advance!

you need use while loop:

<?php $n = rand(5,157); while ($n != 63) { $n = rand(5,157); // n not 63, number } echo 'ok'; ?> 

if check condition once, whereas while check condition until not true


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -