# reset

(PHP 4, PHP 5, PHP 7)

reset — Set the internal pointer of an array to its first element

### Description

reset ( array `&$array` ) : mixed

reset() rewinds `array`'s internal pointer to the first element and returns the value of the first array element.

### Parameters

`array`

  The input array.

### Return Values

Returns the value of the first array element, or `FALSE` if the array is empty.

Warning

This function may return Boolean `FALSE`, but may also return a non-Boolean value which evaluates to `FALSE`. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

### Examples

Example #1 reset() example

`<?php
$array = array('step one', 'step two', 'step three', 'step four');
// by default, the pointer is on the first element
echo current($array) . "<br />\n"; // "step one"
// skip two steps
next($array);
next($array);
echo current($array) . "<br />\n"; // "step three"
// reset pointer, start again on step one
reset($array);
echo current($array) . "<br />\n"; // "step one"
?>`

### Notes

> Note: The return value for an empty array is indistinguishable from the return value in case of an array which has a bool `FALSE` first element. To properly check the value of the first element of an array which may contain `FALSE` elements, first check the count() of the array, or check that key() is not `NULL`, after calling reset().

### See Also

- current() - Return the current element in an array
- each() - Return the current key and value pair from an array and advance the array cursor
- end() - Set the internal pointer of an array to its last element
- next() - Advance the internal pointer of an array
- prev() - Rewind the internal array pointer
- array_key_first() - Gets the first key of an array