Randomizing an Array Using shuffle(), kshuffle(), and array_rand() : shuffle « Data Structure « PHP






Randomizing an Array Using shuffle(), kshuffle(), and array_rand()

 
<?php

  $nums = array(15, 2.2, -4, 2.3, 0);

  shuffle($nums);
  printf("<pre>%s</pre>\n", var_export($nums, TRUE));

  shuffle($nums);
  printf("<pre>%s</pre>\n", var_export($nums, TRUE));

  shuffle($nums);
  printf("<pre>%s</pre>\n", var_export($nums, TRUE));
?>
  
  








Related examples in the same category

1.shuffle( ) function randomizes the position of the elements
2.shuffle.php