In this tutorial, you shall learn how to reverse a string in PHP using strrev() function, with examples.
PHP String Reverse
To reverse a string in PHP, you can use strrev() function. Pass the string as argument to strrev() and the function returns a new string that is formed by reversing the original string.
Examples
1. Reverse a string
In the following example, we will take a PHP String literal and reverse it using strrev() function.
PHP Program
</>
Copy
<?php
$str = 'Welcome to TutorialKart';
$reverse = strrev($str);
echo $reverse;
?>
Program Output
Conclusion
In this PHP Tutorial, we learned how to reverse a string using strrev() function.