PHP | CachingIterator current() Function Last Updated : 20 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The CachingIterator::current() function is an inbuilt function in PHP which is used to return the current element. Syntax: mixed CachingIterator::current( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current value of CachingIterator. Below programs illustrate the CachingIterator::current() function in PHP: Program 1: php <?php // Declare an array $arr = array('G', 'e', 'e', 'k', 's'); // Create a new CachingIterator $cachIt = new CachingIterator( new ArrayIterator($arr), CachingIterator::FULL_CACHE ); // Display the result foreach($cachIt as $element) { echo $cachIt->current() . " "; } ?> Output: G e e k s Program 2: php <?php // Declare an ArrayIterator $arr = array( "a" => "Geeks", "b" => "for", "c" => "Geeks", "d" => "Computer", "e" => "Science", "f" => "Portal" ); // Create a new CachingIterator $cachIt = new CachingIterator( new ArrayIterator($arr), CachingIterator::FULL_CACHE ); // Display the result foreach($cachIt as $element) { echo $cachIt->current() . "\n"; } ?> Output: Geeks for Geeks Computer Science Portal Reference: https://www.php.net/manual/en/cachingiterator.current.php Comment More infoAdvertise with us Next Article PHP | AppendIterator current() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Iterators Similar Reads PHP | AppendIterator current() Function The AppendIterator::current() function is an inbuilt function in PHP which is used to get the current value. Syntax: mixed AppendIterator::current( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current value if it is valid or NULL otherwise. 1 min read PHP | CachingIterator __construct() Function The CachingIterator::__construct() function is an inbuilt function in PHP which is used to construct a new CachingIterator object for the iterator. Syntax: public CachingIterator::__construct( Iterator $iterator, int $flags = self::CALL_TOSTRING ) Parameters: This function accepts two parameters as 2 min read PHP | ArrayIterator current() Function The ArrayIterator::current() function is an inbuilt function in PHP which is used to return the current element of array iterator. Syntax: mixed ArrayIterator::current( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current element of array. 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 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 | CachingIterator rewind() Function 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 Cachi 1 min read Like