PHP’s `strrev()` function flips a string. This straightforward built-in function functions in PHP 8.2 in the same manner as it did in earlier iterations.This is how PHP 8, PHP 8.1, PHP 8.2, PHP 8.3, and PHP 8.4 operate.
Basic Syntax
<?php strrev(string $string): string ?>
Example Usage
<?php $original = "Hello, World!"; $reversed = strrev($original); echo "Original: " . $original . "\n"; echo "Reversed: " . $reversed; ?>
Output:
Original: Hello, World! Reversed: !dlroW ,olleH
The `strrev()` function remains simple and efficient for ASCII strings in PHP 8.2, but for Unicode strings, consider using a multibyte-aware alternative.