Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

shuffle
string
php
communitycreator

What is the str_shuffle() method in PHP?

Programming Bytes

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The str_shuffle method can be used to shuffle a string randomlyRandomly reorder the content of the string..

Syntax


str_shuffle(string $string): string

Return value

This method returns the shuffled string as a new string. The original string remains unchanged.

Code

<?php
$str = '123456';
$shuffled = str_shuffle($str);
echo $shuffled."\n";
$shuffled = str_shuffle($str);
echo $shuffled."\n";
$shuffled = str_shuffle($str);
echo $shuffled."\n";
?>

Explanation

In the code above, we have created a string and shuffled the contents of the string using the str_shuffe method.

RELATED TAGS

shuffle
string
php
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring