PHP reset() Function

The reset() function rewinds array’s internal pointer to the first element and returns the value of the first array element, or FALSE if the array is empty.

Returns the value of the first element in the array on success, or FALSE if the array is empty

ParameterDescription
arrayRequired. Specifies the array to use

Syntax

reset(array) 

Example

$people = array("Cooper", "Samuel", "Lachlan", "James");
echo current($people) . "<br>";
echo next($people) . "<br>";
echo reset($people);

Output

Cooper
Samuel
Cooper

Leave a Reply

Your email address will not be published. Required fields are marked *