English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP str_shuffle() Function Usage and Example

PHP String Character String Functions Manual

The str_shuffle() function is used to randomly shuffle the order of the string.

Syntax

string str_shuffle ( string $str )

Definition and Usage

It is used to randomly shuffle the string

Return Value

It returns the shuffled string

Parameter

Serial NumberParameter and Description
1

string

Input String

Online Example

Try the following example, randomly shuffle all characters in the string and shuffle all the digits in order:

<?php
    //Randomly shuffle all characters in the string
    $input = 'abcdefphp_function_str_shuffle www.oldtoolbag.com';
    $shuffled = str_shuffle($input);
    echo $shuffled;
    echo '<br>';
    //Randomly shuffle the digits
    $number=123456789;
    $shuffled_number = str_shuffle($number);
    echo $shuffled_number;
?>
Test and see‹/›
nfcwfwoccwmlfhnhhr aisupottpf.uo_o_e_sod.ebn
534672819
PHP String Character String Functions Manual