How can I mix up the order of values in an array?
<?php
$values = range("A","Z");
shuffle($values);
print_r($values);
?>
This will print something like the below, shuffling up the letters of the alphabet:
Array
(
[0] => J
[1] => R
[2] => C
[3] => W
[4] => Y
[5] => L
[6] => B
[7] => A
[8] => P
[9] => O
[10] => M
[11] => V
[12] => D
[13] => X
[14] => F
[15] => S
[16] => Q
[17] => G
[18] => I
[19] => H
[20] => N
[21] => Z
[22] => U
[23] => E
[24] => K
[25] => T
)
Comment on this Question and Answer >>>
ASK A QUESTION
More arrays PHP Questions
How do I pick a random value from an array?How do I add to the beginning of an array and find the number of elements in it?
How do I reverse the order of the elements in an array?
How can I display values in a two dimensional array?
How do I change: function wordlimit($string, $length = 50, $ellipsis = "...") { $words = explode(' ', strip_tags($string)); if (count($words) > $length) return implode(' ', array_slice($words, 0, $length)) . $ellipsis; else
