Reverse String Program In PHP

📔 : PHP 🔗
Copy Fullscreen Close Fullscreen
<?php
  function reverse_str($str)
  {
    /*get string length*/
    $length = strlen($str);
    for($i=($length -1); $i >= 0; $i--)
    {
      echo $str[$i];
    }
  }

  /*now test*/
  reverse_str('elephant');
  echo '<br>';
  reverse_str('mohit');
?>
Output
tnahpele
tihom

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook