PHP Array Functions

current() Function

Definition and Usage

The current() function returns the value of the current element in an array.

Every array has an internal pointer to its "current" element, which is initialized to the first element inserted into the array.

Note!

  • This function does not move the arrays internal pointer.

  • Syntax

    current(array)


    Parameter Description
    array Required. Specifies the array to use

    Example

    Output the value of the current element in an array:

    <?php
    $people = array("Peter", "Joe", "Glenn", "Cleveland");

    echo current($people) . "<br>";
    ?>

    Run Example>>