PHP Code to find the reverse of a number

Description


This program finds the reverse of a number using do while loop.

code


<html>
<head>
<title>REVERSE OF A NUMBER</title>
</head>
<body>
<font size=7>REVERSE OF A NUMBER</font>
<form action=reverse.php method="post">
ENTER NUMBER:<input type="text" name="t1">
<br><br>
<input type="submit" value="REVERSE">
<?php
if(isset($_POST["t1"]))
{
$n=$_POST["t1"];
$rev=0;
do
{
$t=$n%10;
$rev=($rev*10)+$t;
$n=floor($n/10);
}
while($n>0);
echo 'Reverse is ';
echo $rev;
}
?>
</form>
</body>
</html>

Output



PHP Program to find the reverse of a number

No comments: