php - How to randomize an array without duplicating an integer -


for example if have this:

<?php $b = array(100); ($i = 1; $i <= 100; $i++) {     $b[$i]=$i; } ?> 

how randomize numbers without duplicating them?

your approach work if shuffle array:

for ($i = 1; $i <= 100; $i++) {     //$b = array(100); //why here?     $b[$i] = $i; } shuffle($b); 

however it's simpler:

$b = range(1, 100); shuffle($b); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

asp.net ajax - Jquery scroll to element just goes to top of page -