Some time ago during a job interview I got the task to reverse a string in PHP without using strrev.
strrev
My first solution was something like this:
Here is my code to solve your problem