PHP reset array function
Last Updated: February 21, 2022
reset – Set the internal pointer of the array to its first element.
Syntax
reset(array|object &$array): mixed
Supports (PHP 4 , PHP 5, PHP 7, PHP 8)
Parameters
Parameter | Description |
array | The input array |
Return Value
Returns the value of the first array element, or false
if the array is empty.
Example
$array1 = array('a', 'c', 'b', 'D', 'E', 'F');
next($array1); // 'c';
next($array1); // 'b';
echo reset($array1); // 'a';
Output
a