sábado, 17 de diciembre de 2016

php reset

Example #1 reset() example

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.
<?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"

?>

No hay comentarios:

Publicar un comentario