I have an array like this $arr = [1,2,4,5,6,7,8,9] but I need a random version of this array, I was using the function shuffle like this $random = shuffle($arr) but this function just returns true and not a random version of the array.
2 Answers
This function shuffles (randomizes the order of the elements in) an array. It uses a pseudo random number generator that is not suitable for cryptographic purposes.
The reason why you are getting true is because the shuffle function randomizes the elements correctly.
The array is passed by reference and not by value which mean that the next time you access the array it should be randomized
shufflebut you do not need to assign the result - at least not to the same variable name, so simply$res = shuffle( $arr );