mercredi 5 octobre 2016

php random number within range - no repeat

Haven't been able to find what I'm looking for so far, so I'm asking for help.

I have a div with a class that needs to end in a number between 1 and 8, and I need it to be a random number, without repeating...

<div class="parallax parallax_<?php echo $random_number ?>"></div>

I figured this should be pretty simple, but I'm having trouble.

Currently, I have:

<div class="parallax parallax_<?php echo rand(1, 8); ?>"></div>

which works, but produces duplicates.




Aucun commentaire:

Enregistrer un commentaire