reset

mixed reset(array array) 

Moves the internal array pointer to the first element of the array and returns that element’s value.

Returns:

Value of the first element of the array; FALSE if there is no first element

Description:

This function resets the internal array pointer to the first element of array and returns the value of that element. The order in which PHP keeps the array is the same order in which the elements were put into the array by the use of any of the element-addition functions such as array(), push(), and so on.

Version:

PHP 3, PHP 4

See also:

end() 
key() 
current() 
next() 
prev() 

Example:

Reset the internal array pointer
 $my_array = array('a', 'b', 'c', 'd', 'e'); echo current($my_array); for ($i = count($my_array); $i ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.