How To Implement Code For Reverse Numbers Using PHP

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

we can reverse number using while loop in php.so today we discuss how to do it.

How To Implement Code For Reverse Numbers Using PHP

Complete Code For Reverse Numbers Using PHP.

<!DOCTYPE html>
<html>
<head>
    <title>How To Implement Code For Reverse Numbers Using PHP</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
    body {
        background: black;
    }

    .form-control {
        width: 80%;
    !important;
    }
</style>
<body>
<body>
<div class="container">
    <br/><br/>
    <div class="text-center">
        <h1 id="color" style="color: white;">Reverse Numbers Using PHP</h1>
    </div>

    <div class="well">
        <form method="post">
            Enter a Number: <input class="form-control" type="text" name="number"><br><br>
            <input type="submit" class="btn btn-success" name="submit" value="Submit">
        </form>
        <?php
        if (isset($_POST['number'])) {
            $num = $_POST['number'];

            $revnum = 0;
            while ($num > 1) {
                $rem = $num % 10;
                $revnum = ($revnum * 10) + $rem;
                $num = ($num / 10);
            }
            echo "Reversed number: $revnum";

        }
        ?>
    </div>
</div>
</body>
</html>

Related Post