PHP » Arrays » current()

Syntax:
mixed current(array array)
array
The array to get the current element from.

Returns the current element.

Arrays have an internal pointer that keeps track of the "current" element. This function returns that element.

Examples

Code:
<?php

$array1 = array("one", "two", "three");

while ($element = current($array1)) {
   print "$element ";
   next($array1);
}

?>
Output:
one two three
Explanation:

The code uses the current() and next() functions to print all the elements in an array.

See Also: