Computer >> Computer tutorials >  >> Programming >> PHP

strrev() function in PHP


The strrev() function is used to reverse a string. It returns the reversed string.

Syntax

strrev(str)

Parameters

  • str − The string to be reversed

Return

The strrev() function returns the reversed string.

Example

The following is an example −

<?php
   echo strrev("Jack");
?>

Output

The following is the output −

kcaJ

Example

Let us see another example −

<?php
   $val = 7837;
   echo strrev($val);
?>

Output

The following is the output −

7387