Home » PHP » How to Reverse a String in PHP?

How to Reverse a String in PHP?

In PHP, there is a predefined function strrev(), which is used to reverse a string.

Now I will give a program for reverse a string "welcome":

<html>
<body>
<?php
$a="welcome";
$b=strrev($a);
echo $b;
?>
</body>
</html>

Output: emoclew

See also: