PHP 4, PHP 5, PHP 7, PHP 8
reset - Set the internal pointer of an array to its first element
Code Examples

reset( array|objectarray ): mixed

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



The input array.

Return Values

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


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.



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.


Version Description
8.1.0 Calling this function on objects is deprecated. Either use get_mangled_object_vars on the object first, or use ArrayIterator.

Related Functions

Example of reset

Show all examples for reset

PHP Version: