PHP | CachingIterator rewind() Function Last Updated : 26 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The CachingIterator::rewind() function is an inbuilt function in PHP which is used to rewind the iterator. Syntax: void CachingIterator::rewind( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the CachingIterator::rewind() function in PHP: Program 1: php <?php // Declare an ArrayIterator $arr = new ArrayIterator( array( "a" => 4, "b" => 2, "g" => 8, "d" => 6, "e" => 1, "f" => 9 ) ); // Create a new CachingIterator $cachIt = new CachingIterator( new ArrayIterator($arr), CachingIterator::FULL_CACHE ); // Move to last position $cachIt->seek(5); // Display the next value var_dump($cachIt->next()); // Move to start position $cachIt->rewind(); // Display the current element echo $cachIt->current(); ?> Output: NULL 4 Program 2: php <?php // Declare an ArrayIterator $arr = new ArrayIterator( array( "b" => "for", "a" => "Geeks", "e" => "Science", "c" => "Geeks", "f" => "Portal", "d" => "Computer" ) ); // Create a new CachingIterator $cachIt = new CachingIterator( new ArrayIterator($arr), CachingIterator::FULL_CACHE ); // Check the validity of ArrayIterator while($cachIt->valid()) { $cachIt->next(); } // Move to start position $cachIt->rewind(); // Display the current element echo $cachIt->current(); ?> Output: for Reference: https://www.php.net/manual/en/cachingiterator.rewind.php Comment More infoAdvertise with us Next Article PHP | AppendIterator rewind() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Iterators Similar Reads PHP | AppendIterator rewind() Function The AppendIterator::rewind() function is an inbuilt function in PHP which is used to rewind to the first element of the first inner Iterator. Syntax: void AppendIterator::rewind( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. B 1 min read PHP | ArrayIterator rewind() Function The ArrayIterator::rewind() function is an inbuilt function in PHP which is used to rewind the array back to the start. Syntax: void ArrayIterator::rewind( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrat 1 min read PHP | CachingIterator key() Function The CachingIterator::key() function is an inbuilt function in PHP which is used to return the key for the current element. Syntax: scalar CachingIterator::key( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the key value of the current element. B 1 min read PHP | CachingIterator setFlags() Function The CachingIterator::setFlags() function is an inbuilt function in PHP which is used to set the flags for the CachingIterator object. Syntax: void CachingIterator::setFlags( int $flags ) Parameters: This function accepts a single parameter $flags which holds the value of bitmask of the flags to set. 1 min read PHP | CachingIterator next() Function The CachingIterator::next() function is an inbuilt function in PHP which is used to move the iterator to the forward. Syntax: void CachingIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate 1 min read PHP | DirectoryIterator rewind() Function The DirectoryIterator::rewind() function is an inbuilt function in PHP which is used to rewind the DirectoryIterator back to the start position. Syntax: void DirectoryIterator::rewind( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any va 2 min read Like