PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP - String str_shuffle() Function



The PHP String str_shuffle() function returns the string with randomly shuffled all characters of the specified string.

Syntax

str_shuffle(string)

Parameters

string Required. Specify the string to randomly shuffle

Return Value

Returns the randomly shuffled version of the specified string.

Example:

In the example below, str_shuffle() function returns a string with randomly shuffled all characters of the given string.

<?php
$MyString = "HELLO WORLD";
$NewString = str_shuffle($MyString);

echo $NewString."\n";
?>

The output of the above code will be:

EHOLL WRLOD

❮ PHP String functions

5