PHP program to reverse a number

PHP program to reverse a number:

The below program can be used to reverse a given number using a loop. The PHP echo statement is used to output the result on the screen.

Reverse Number of 123456789= 987654321.

<!DOCTYPE html>
$num = 123456789;  
$x = 0;
$n =$num;
$mod = $num%10;
$x = $x * 10 + $mod;  
$num = $num/10;
echo "Reverse of $n is $x.";


Reverse of 123456789 is 987654321.
Content Protection by
Please Share