Write a program to reverse of string in php

In this article, We’ll write a program to reverse of a string without using php in-built function strrev in php.

For example, we’ve a string “nexladder web tutorials”, let’s see what output will come when we reversed the string.

    $string = "nexladder web tutorials"; 
    $str_len = strlen($string); // calculate the length of string
    for ($i = $str_len; $i >= 0; $i--)  {  
      echo $string[$i];
    // Output slairotut bew reddalxen

That’s it!. Please share your thoughts or suggestions in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *