Some time ago during a job interview I got the task to reverse a string in PHP without using strrev.
My first solution was something like this:
You can use this code to reverse a string without using the reserved function in php.
Code:
=0; $x--) {
$y .= $y[$x];
$y[$x] = NULL;
}
echo $y;
}
str_rev("I am a student");
?>
Output:
tneduts a ma I
In the above code, we have passed the value of the string as the parameter.We have performed the string reversal using for loop.