str_shuffle() function randomly shuffles the characters of a
string. It generates a different order of characters each time it is called.
str_shuffle() function takes one required parameter: a
$string that is a
string to be shuffled. It returns a
string with the shuffled characters.
The following example uses the
str_shuffle() function to shuffle the letters of the word
"secret". Then the
echo command prints the shuffled letters as a
string to the console:
The example can result in the following output (it can be any combination of the given letters):
This example uses the
str_shuffle() function with a
Note: The output will vary each time this program is executed, as the
str_shuffle()function shuffles the string randomly. The function should not be used for cryptography because it does not generate cryptographically secure random numbers.