PHP current function

Last Updated: February 19, 2022

current — Get the current element of the array

Every array has an internet pointer pointing at the current element.

Syntax

current(array|object $array): mixed

Supports (PHP 4 , PHP 5, PHP 7, PHP 8)

Parameters

Parameter Description
value target array

Return Value

Returns the current element of the array

Example

$numbers = array("1","2","3");
print_r(current($numbers));
next($numbers);
print_r(current($numbers));

Output

12
Test