Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • array pointer changing functions php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 105
    Comment on it

    Welcome to FindNerd. We are going to discuss the in-build functions in php to handle the pointer of the array. You can easily get the current pointer of the array by using current() function, next function will advance the pointer of the array and prev function will move the pointer one element back. Please have a look.

    <?php
    $myArr = array('Deepak','Verma','Saharanpur','UP');
    echo current($myArr);
    echo '<br />' . next($myArr);
    echo '<br />' . current($myArr);
    echo '<br />' . prev($myArr);
    echo '<br />' . current($myArr);
    ?>
    result:
    Deepak
    Verma
    Verma
    Deepak
    Deepak
    

    In above example we created an array with four elements. you used the function current to get the current element, used the next fnction to move the pointer forward and prev function to move the pointer backward. In the end we used current to get the current element. Hope this 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: