In this blog you will see how to create a reverse number program in PHP.
NOTE:- We will use the while loop here to create a reverse number program
Table of Contents
Reverse Number Programs Live Example.
Live Output:-
Reverse Number Programs in PHP with Myprograming
Today we will learn reverse number programs in PHP with Myprogramming.
PHP Coding here
<!DOCTYPE html>
<html>
<head>
<title>Reverse Number Programs php with myprograming</title>
</head>
<style type="text/css">
.class1{
text-align: center;
}
.class1 form{
background: #f5f5ff;
padding: 50px 0;
}
.class1 form input{
width: 300px;
height: 50px;
}
</style>
<body>
<div class="class1">
<h1>Reverse Number Programs in PHP with <a href="https://www.myprograming.com/">Myprograming</a></h1>
<form method="POST" action="#">
<h2><b>Demo:- Number :4321 = 1234 </b></h2>
<br><input type="text" name="number" placeholder="Enter Your number to reverse">
<br><br>
<input type="submit" name="submit">
</form>
</div>
<?php
if (isset($_POST['submit'])) {
$num = $_POST['number'];
$rev =0;
while ($num > 1)
{
$rem = $num % 10;
$rev = ($rev* 10) + $rem;
$num = ($num / 10);
}
echo "<p align='center'>Reverse number is: <b>$rev</b></p>";
}
?>
</body>
</html>
Copy the code here and paste it into your index.php File.