str_shuffle()

The str_shuffle() function randomly shuffles a string. It generates a different order of characters each time it is called.

Syntax

str_shuffle($string)
  • $string is the string to be shuffled.

Codebyte Example

This example demonstrates the use of str_shuffle() on a string.

Code
Output
Loading...

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.

All contributors

Looking to contribute?

Learn PHP on Codecademy