Rand() within the for

Asked

Viewed 36 times

0

I have the following condition of FOR:

<? for($i=0; $i<=9; $i++){ ?>
    <input type="button" value="<?=$i?>" name="no" onclick="moveNumbers(this.value)" class="btn btn-default">  
<? } ?>

I’d like it if instead of displaying 0, 1, 2, 3... it exhibited randomly. How can I do this?

  • And the problem with the rand()/mt_rand()?

  • I can’t explain it, I needed it within the numerical digits to display randomly...

  • value="<?=mt_rand(1,10)?>" what’s wrong with that?

  • http://prntscr.com/b5i7gt

1 answer

-2

In this example generates numbers between 0 and 100, just change the range you want in rand(MIN, MAX)

<? for($i=0; $i<=9; $i++){ 
      srand(make_seed());?>
    <input type="button" value="<?=rand(0, 100)?>" name="no" onclick="moveNumbers(this.value)" class="btn btn-default">  
<? } ?>
  • I’ve tried that way, he repeats the numbers.. :(

  • uses with srand(make_seed()); Primiero, see how it is now

Browser other questions tagged

You are not signed in. Login or sign up in order to post.