0
I am developing a numeric keyboard, however, when printing the variable num
, the numbers get repeated, I’m trying to make them random.
<?php
for($i=0; $i<=9; $i++){
$num = rand(0,9)
?>
<button class='btn btn-default' style='margin-top: 5px'><?php echo $num;?></button>
<?php } ?>
Just one detail: you don’t want to generate random numbers. Numbers will always be the same. What you need is to scramble the data:
shuffle
.– Woss
I’m using PHP @Maniero
– Sr. André Baill
@Andersoncarloswoss exactly like that
– Sr. André Baill
It shall be duplicated: https://answall.com/q/183927/5878, or https://answall.com/q/31161/5878, or https://answall.com/q/102405/5878
– Woss
With shuffle solved, thank you.
– Sr. André Baill
That’s what we call chameleon question, Because you ask one question and I want to know another. The way you asked it became explicit that you wanted to generate 10 random numbers without repetition within the range [0, 9]. It would generate the expected result and the solution was discussed in the questions linked by Maniero; the only thing is that it is not the simplest way to solve.
– Woss