PHP.nl

reset

reset

Set the internal pointer of an array to its first element

mixed **reset**  $array
rewinds 's internal

pointer to the first element and returns the value of the first array element. reset``array

arrayThe input array.

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

Voorbeeld: 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"

?>

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

current``each``end``next``prev``array_key_first