How to reverse a string without using Builtin Function in PHP

You wonder how to reverse a String without using a Built in Function strrev() in PHP?.
This question asked many times in Interviews.

I got a solution here.

Just see the below lines of codes.

$str = "SPIDERMAN";
$len = strlen($str);
for($i=$len-1; $i>=0; $i--)
echo $str[$i];

First calculate the string length using the “strlen()” function.

After finding the length just loop through the string and print one by one.

Do you know how to reverse a string not using any Loops or any Built in function like “strlen()”?.

Get the solution here CLICK HERE



Add a Comment

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