Example 1 — Shuffle a String
The characters change order, but the length stays the same.
<?php
$shuffled = str_shuffle("PHP123");
echo strlen($shuffled), PHP_EOL; How It Works
- Pass a six-character string to str_shuffle.
- PHP rearranges the characters randomly.
- The exact order changes on every run.
- The length is always 6, so strlen prints 6.

