reset() function in PHP

PHPProgrammingServer Side Programming

The reset() function sets the internal pointer of an array to its first element. It returns the value of the first array element. It returns FALSE if the array is empty

Syntax

reset(arr)

Parameters

  • arr − The array to be used

Return

The reset() function returns the value of the first array element. It returns FALSE if the array is empty.

Example

The following is an example −

Live Demo

<?php
   $arr = array("one", "two","three", "four", );
   echo current($arr);
   echo next($arr);
   echo next($arr);
   echo reset($arr);
   echo next($arr);
?>

Output

one
two
three
one
two
raja
Published on 15-Oct-2018 11:39:26

Advertisements