PHP reset() Function Last Updated : 20 Jun, 2023 Comments Improve Suggest changes Like Article Like Report 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. Syntax: reset($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: Program 1: php <?php // input array $arr = array('Ram', 'Rahim', 'Geeta', 'Shita'); // here reset() function Moves the internal pointer to the // first element of the array, which is Ram and also returns // the first element $res = reset($arr); print "$res"; ?> Output: Ram Program 2: php <?php // Input array $arr = array('Delhi', 'Kolkata', 'London'); // getting current element using current() // function print current($arr)."\n"; // move internal pointer to next element next($arr); print current($arr)."\n"; // now reset() is called so that the internal pointer // moves to the first element again i.e, Delhi. reset($arr); print current($arr); ?> Output: Delhi Kolkata Delhi Reference: https://www.php.net/manual/en/function.reset.php Create Quiz Comment K Kanchan_Ray Follow 0 Improve K Kanchan_Ray Follow 0 Improve Article Tags : Misc Web Technologies PHP PHP-array PHP-function +1 More Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like