← All built-ins / str_shuffle()

str_shuffle()

str_shuffle(string $s): string

Parameters

NameTypeDescription
$sstringinput string

Return value

The characters in random order (not cryptographically secure).

Example

$sh = str_shuffle("abcdef");
echo strlen($sh) == 6 && str_contains($sh, "a") ? "ok" : "bad";
ok

See also

shuffle()rand()