PHP Function Reference

PHP strrev() Function



The PHP strrev() function returns the string that is reverse of the specified string.

Syntax

strrev(string)

Parameters

string Required. Specify the string to reverse

Return Value

Returns the reversed string.

Example:

In the example below, strrev() function is used to reverse a given string.

<?php
$str = "Hello World!";
$reversed_str = strrev($str);

echo $str."\n";
echo $reversed_str."\n";
?>

The output of the above code will be:

Hello World!
!dlroW olleH

❮ PHP String Reference