PHP | AppendIterator valid() Function Last Updated : 21 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The AppendIterator::valid() function is an inbuilt function in PHP which is used to check the validity of the current element. Syntax: bool AppendIterator::valid( void ) Parameters: This function does not accept any parameters. Return Value: This function returns TRUE if the current iteration is valid and FALSE otherwise. Below programs illustrate the AppendIterator::valid() function in PHP: Program 1: php <?php // Declare an ArrayIterator $arr = new ArrayIterator(array('G', 'e', 'e', 'k', 's')); // Create a new AppendIterator $itr = new AppendIterator; $itr->append($arr); // Check the validity and display // the result while($itr->valid()) { echo $itr->current(); $itr->next(); } ?> Output: Geeks Program 2: php <?php // Declare an ArrayIterator $arr1 = new ArrayIterator(array("Geeks", "for", "Geeks")); $arr2 = new ArrayIterator(array("Computer", "Science", "Portal")); // Create a new AppendIterator $itr = new AppendIterator; $itr->append($arr1); $itr->append($arr2); // Using rewind function $itr->rewind(); // Check the validity and display the result while($itr->valid()) { var_dump($itr->current()); // Moving to next element $itr->next(); } ?> Output: string(5) "Geeks" string(3) "for" string(5) "Geeks" string(8) "Computer" string(7) "Science" string(6) "Portal" Reference: https://www.php.net/manual/en/appenditerator.valid.php Create Quiz Comment J jit_t Follow 0 Improve J jit_t Follow 0 Improve Article Tags : Web Technologies PHP PHP-function 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