PHP string str_shuffle() function

The str_shuffle() is in-built function of PHP. It is used to randomly shuffle all the character of a string. One Permutation of all possible is created.

Note: This function "str_shuffle()" does not generate cryptographically secure value. If we want to cryptographically secure then use it :

Random_int(), random_byte() etc.

Syntax:

ParameterDescriptionRequired/Optional
StringSpecify string to shuffleRequired.

Example 1

Output:

Before using 'str_shuffle()':Hello PHP
Before using 'str_shuffle()':oP ePlHHl

Example 2

// In this program I have used, the output of the given above program. To check that it return randomly data or not. But when we will use "str_shuffle()" function then it will return randomly data.

Output:

Before using 'str_shuffle()':oP ePlHHl
Before using 'str_shuffle()':ePoll HHP

Note: This function returns randomly data so you can refresh your page then see.

Example 3

Output:

Before using 'str_shuffle()':12345
Before using 'str_shuffle()':15432
http://php.net/manual/en/function.str-shuffle.php

Next TopicPHP String




Latest Courses