What potential pitfalls should be considered when using strrev function in PHP?

One potential pitfall when using the strrev function in PHP is that it reverses the characters in a string, which may not always be the desired outcome. If the string contains multibyte characters (such as emojis or special characters), using strrev may result in unexpected behavior or corrupted data. To avoid this issue, consider using mb_strrev function from the mbstring extension, which properly handles multibyte characters.

function mb_strrev($string){
    return join('', array_reverse(preg_split('//u', $string)));
}

// Example usage
$string = "Hello 😊";
$reversedString = mb_strrev($string);
echo $reversedString; // Output: 😊 olleH