PHP Strrev() function
Syntax
strrev(string) ;
Parameter | Description |
String | Any String (Required) |
Definition
It returns the reverse of string.
Usage
Strrev function is used to reverse the string. For example java is a string, strrev function return avaj.
Example of strrev function
<?php echo strrev("Welcome to PHP"); ?>
- Example
- Run
In above example Welcome to PHP is a simple string, pass this string into the strrev function and its return the reverse of the string.
Reverse number using strrev
<?php $a=387; $b=strrev(123); echo $b; ?>
Output
321
You can also use strrev function to reverse the number as shown above.
More example of strrev function
<?php echo "Before reverse:
"; $a="Hypertext pre-processor"; echo $a."
"; echo "The reverse string :
"; echo strrev($a); ?>
- Example
- Run
In above example $a is a string variable, you can see the result before and after using strrev function.