strrev

string strrev(mixed string) 

Reverses a string.

Returns:

String

Description:

strrev() reverses the order of the characters in any string or number passed to it.

Version:

PHP 3+, PHP 4+

See also:

To reverse an array:

array_reverse() 

Example:

Reverse a string
<?php 
$palindrome = 'Young Ada had a gnu. Oy!'; 

echo "Original string          : $palindrome\n", 
     'strrev ($palindrome)     : ', strrev ($palindrome); 
?> 

Output: 
Original string     : Young Ada had a gnu. Oy! 
strrev ($palindrome): !yO .ung a dah adA gnuoY 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.