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:
Try this:
$s = 'abcdefg'; for ($i = strlen($s)-1; $i>=0; $i--) { $s .= $s[$i]; $s[$i] = NULL; } var_dump(trim($s));