PHP » Arrays » reset()

Syntax:
mixed reset(array array)
array
Array for which the pointer should be reset to the beginning.

Resets an array pointer.

The internal pointer of an array can be reset to the first element with the reset() function. It also returns the first element of the array.

Examples

Code:
<?php

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

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

print "<br>" . reset($array1);

?>
Output:
one two three
one
Explanation:

After looping through the array, it is reset to the beginning using the reset() function.

See Also: