The reset() function is an inbuilt function in PHP.
- This function is used to move any array’s internal pointer to the first element of that array.
- While working with arrays, it may happen that we modify the internal pointer of an array using different functions like prev() function, current() function, key() function etc.
- The reset() function resets the internal pointer to point to the first element of the array.
Parameters: This function accepts a single parameter $array. It is the array for which we want to reset the internal pointer to point to the first element again.
Return Value: It returns the first element of the array on success, or FALSE if the array is empty i.e, the array does not contain any element.
Below programs illustrate the reset() function in PHP:
Delhi Kolkata Delhi
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.