rev

How to reverse a string without using Loops and Builtin Function in PHP

Do you know how to reverse a string without using any loops or built in function in php?

There is an amazing recursive function will do this magic trick.

See the below lines of codes:


<?php

function myreverse($str)
{
return $str?myreverse(substr($str,1)).$str[0]:'';
}
echo myreverse("SUPERMAN");

?>

The above function will give the reverse result. Just pass the parameter.

 

About the Author

agurchand

Software Engineer, Blogger etc., Visit my Youtube channel - <a href="http://www.youtube.com/agurchand">Click Here</a>

2 thoughts on “How to reverse a string without using Loops and Builtin Function in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *