Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Reverse the string without array_reverse function

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 210
    Comment on it

    Welcome to FindNerd. Today we are going to tell the way how we can reverse a string without using array_reverse function in php. Please have a look.

    $string = "FINDNERD";
    $count=array_sum(count_chars($string));
    
    for($i=$count -1 ;$i>=0;$i--){
            echo $string[$i];
    }
    result : DRENDNIF
    

    In above example we store the string in variable $string and count the length of the string. We are using a for loop to reverse the string. It is simple way to reverse the string. Hope it helps.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: