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 -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -