The PHP Function Str_Shuffle
The php function str_shuffle randomly shuffles the characters of a string. It accepts a single parameter that specifies the string whose characters need to be shuffled. The shuffled string is returned as the output of the function. It is a good function to use when you need to create a password or add some randomness to the data in your application. The output of the function will be different every time it is executed because the shuffling of characters takes place randomly.
In the following example, you shuffle the State and ZIP columns in a table. You enter the Shuffle Function for the column that will be replaced with shuffled values, and you edit the Column Map to remove the names of any other source columns that have replacement values that match the shuffled value. The shuffle function will ignore any rows in the table that contain a NULL, SPACES, or zero-length VARCHAR value as well as any replacement row that does not match the shuffled value. The number of times that the shuffle function will refetch a replacement row before giving up is indicated by a “retry” value.
The shuffle function works by using the operating system’s CSPRNG. As a result, it should not be used for cryptography, or for purposes that require the resulting values to be unguessable. You should instead use functions such as random_int() and random_bytes() to generate cryptographically secure random numbers. For more information, see the documentation for these functions.