Simple Script Reverse a String in PHP

Its almost the end of the semester, and after that everyone will be out looking for a job. One thing i have noticed is that most entrance exams for programming involves some sort of a test whether you know how to code. Most of these exams would ask the applicant to manipulate a string or solve a simple problem.

Of all these exams, i found out that the reverse string is the most common. Here is a sample below:

$orig = "reverse";
for ($i=strlen($orig); $i>=0; $i--)
	$temp .= $orig[$i];
echo $temp;

Good Luck.

Leave a Reply