Computer >> Computer tutorials >  >> Programming >> PHP

str_shuffle() function in PHP


The str_shuffle() function is used to randomly shuffle a string.

Syntax

str_shuffle(str)

Parameters

  • str − The string to shuffle

Return

The str_shuffle() function returns the shuffled string.

Example

The following is an example −

<?php
   echo str_shuffle("Welcome");
?>

Output

clemWeo

Example

The following is an example −

<?php
   $mystr = 'demo';
   $shuffled_str = str_shuffle($mystr);
   echo $shuffled_str;
?>

Output

eomd