PHP provides useful string manipulation functions like strrev() and str_shuffle() that allow you to reverse a string and shuffle its characters. These functions are commonly used in password generation, text transformations, and learning string behavior.
strrev() reverses the entire string character by character.str_shuffle() randomly rearranges all characters.strrev(string) → returns reversed stringstr_shuffle(string) → returns shuffled string
// Reverse a string using strrev()
<?php
$string = "Hello";
$reversed = strrev($string);
echo $reversed;
?>
olleH
// Shuffle characters randomly using str_shuffle()
<?php
$string = "Hello";
$shuffled = str_shuffle($string);
echo $shuffled;
?>
Random output such as olHle or lHoel
strrev() reverses everything including spaces and symbols.str_shuffle() is non-deterministic; results vary each run.str_shuffle() for cryptographic security.