Skip to content

Instantly share code, notes, and snippets.

@niravmadariya
Created June 7, 2018 07:00
Show Gist options
  • Save niravmadariya/8b6d594644da89c20ebebe1c15a7a410 to your computer and use it in GitHub Desktop.
Save niravmadariya/8b6d594644da89c20ebebe1c15a7a410 to your computer and use it in GitHub Desktop.
<html>
<head><title>Reverse of a given Number in PHP</title></head>
<body>
<form method="post">
Enter the Number:<br>
<input type="number" name="number" id="number">
<input type="submit" name="submit" value="Submit" />
</form>
<?php
if($_POST['submit']){
$num = $_POST['number'];
$revnum = 0;
while ($num > 1)
{
$rem = $num % 10;
$revnum = ($revnum * 10) + $rem;
$num = ($num / 10);
}
echo "Reverse number of 23456 is: $revnum";
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment