Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use current() function and end() function in php ?

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 124
    Comment on it

    why use current() function:

    current() returns the value of the current element in an array:

    Syntax of current() function:

    current(array)

    why use end() function:

    end() returns the value of the last element in an array:

    Syntax of end() function:

    end(array)

    You can take reference form below example to use of current() function and end() function.

    <?php
    //people is a varible name
    $people = array("ben", "mac", "jorden");
    
    //call the current()
    echo current($people) . "<br>";
    
    //call the end()
    echo end($people); 
    ?>
    

    output will come following:

    1-when call current() then,

    output will come:

    ben

    2-when call end() then,

    output wil come:

    jorden

 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: