PHP Tutorial - PHP str_shuffle() Function






Definition

The str_shuffle() function randomly shuffles all the characters of a string.

Syntax

PHP str_shuffle() Function has the following syntax.

str_shuffle(string)

Parameter

ParameterIs Required Description
stringRequired. String to shuffle

Return

PHP str_shuffle() function returns the shuffled string

Example

Randomly shuffle all characters of a string:


<?php
echo str_shuffle("Hello World from java2s.com");
?>

The code above generates the following result.