How to Reverse a String in PHP?


You have a string(ex. gnirts a esrever rof si noitcnuf )(verrts) whose characters are written in reverse order. To, read the string, you’re looking a way to reverse the string.


PHP has a built in function, strrev() which can reverse a string. You just mention a string in its parameter and it will return the reversed string.

To reverse our string, lets see the following example-

echo strrev("gnirts a esrever rof si noitcnuf )(verrts");

strrev() function is for reverse a string