Reverse Number
This algorithm reverse the given number. For example if given number is 123 then output number will be 321.
function Reverse($num)
{
$reverse = 0;
while ($num != 0)
{
$reverse *= 10;
$reverse += $num % 10;
$num = (int)($num / 10);
}
return $reverse;
}
Example
$rev = Reverse(1234);
Output
4321