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 ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook