shuffle() is the way here. It prints 1 because shuffle modifies the array in place and returns a boolean value, as written in the documentation :
Returns TRUE on success or FALSE on failure.
I suggest also reading the documentation for array_rand() :
Selects one or more random entries from the array, and returns the key (or keys) of the random entries.
Always read the documentation if you use the built-in functions. Do not just assume how work. I bet it took more time to write a question than to look at it.
Felix kling
source share