PHP 8.1.15 Released!

Random\Randomizer::shuffleBytes

(PHP 8 >= 8.2.0)

Random\Randomizer::shuffleBytesGet a byte-wise permutation of a string

Description

public Random\Randomizer::shuffleBytes(string $bytes): string

Returns a uniformly selected permutation of the input bytes.

Each possible permutation of the input bytes is equally likely to be returned.

Parameters

bytes

The string whose bytes are shuffled.

The input string will not be modified.

Return Values

A permutation of the bytes of bytes.

Errors/Exceptions

Examples

Example #1 Random\Randomizer::shuffleBytes() example

<?php
$r
= new \Random\Randomizer();

// Shuffle bytes in a string:
echo '«', $r->shuffleBytes( "PHP is great!" ), "»\n";
?>

The above example will output something similar to:

« ga rHs!PPiet»
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top