PHP reset() Function

PHP reset Function


Definition :

In php Array function reset function is inbuilt function.The reset() function is used to  moves the internal pointer to the first element of the array.

Related methods:

  • current() - returns the value of the current element in an array
  • end() - moves the internal pointer to, and outputs, the last element in the array
  • next() - moves the internal pointer to, and outputs, the next element in the array
  • prev() - moves the internal pointer to, and outputs, the previous element in the array
  • each() - returns the current element key and value, and moves the internal pointer forward
Syntax

    reset(array)

Parameter 
Parameter Description
array Required. Specifies the array to use

 Example1 : Given below example Output the value of the current and next element in an array, then reset the array's internal pointer to the first element in the array

Output :

Web
Desinging
Web

Example2 : A demonstration of all related methods

Output :

Apple
Mango
Mango
Apple
Banana
Apple