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

rev

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.

 

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

    1. Thanks Marty, Actually this tutorials is about without using build-in function strrev() only. 😉

Leave a Reply

Theme: Overlay by Kaira
Agurchand