How To Implement Code For Reverse The String Using PHP

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

Using while loop we can reverse give input string .So today we discuss how to do it .

How To Implement Code For Reverse The String Using PHP

Complete Code For Implementing Code For Reverse The String Using PHP

<!DOCTYPE html>
<html>
<head>
    <title>How To Implement Code For Reverse The String 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 the String Using PHP</h1>
    </div>

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

            $length = strlen($string);
            for ($i=($length-1) ; $i >= 0 ; $i--)
            {
                echo $string[$i];
            }
        }
        ?>
    </div>
</div>
</body>
</html>

Related Post