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

python - PyInstaller UAC not working in onefile mode -

python - RuntimeError: can't re-enter readline -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -