PHP Program to reverse a string

Write a PHP program to reverse a string without strrev function.

<html>

<body>
    <form action="" method="POST">
        <H1>Biodata</h1>
        Enter the string :
        <input type="text" name="str" />
        <input type="submit" />
    </form>

</html>
<?php
if ($_POST) {
    $string = $_POST["str"];
    $len = strlen($string);
    for ($i = ($len - 1); $i >= 0; $i--) {
        echo $string[$i];
    }
}
?>
Output
reverse php
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments