Php random numbers

I need to print out random numbers from 0 to 100. With rand() I can’t do that, because prints out only one nr each time. What I want is to have on my page all the numbers from 1 to 100 in a random way without repeating a number.
Can someone give a hand?

$nums = range(0,100);

Weird, I actually wrote about this this morning:

Think mine was easier :stuck_out_tongue_winking_eye:

Thank you, but how can I have the numbers on the screen without the array? I mean just the numbers : 2, 5, 45, etc

echo implode(", ",$nums);



Thank you again. I found how to do it with foreach loop.

foreach($nums as $num){
    echo $num . "<br />\

Would be a lot cleaner…and wouldn’t require modification if you needed a larger or smaller number of values.

The other posted snippet will act much more quickly than yours: the closer you get to your max value, the more likely it is that you’re going to see repeats, which means your loop would (for example) have to run many more than 100 times to get 100 values. At a max value of 100, I wouldn’t be surprised if your loop was actually running upward of a thousand times before finally filling the array.

The other code only ever runs once.