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 can I check if a value is already in an array?I have an array of a hundred or so lines, each line has data with "|" separated values. I need to scan through this array, and select the line whose first 5 characters matches a text string. Any ideas or questions?
I want to invert my array, can I do this?
Hi. i have a music samples website. in one table, id like a different sample to appear every time the page is refreshed. how do i acheve this? how can i alterate and retrieve these bloody mp3's? surely i can use a PHP script? thankyou
what is the return value of array_unique()?
