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 Comment More infoAdvertise with us Next Article PHP | AppendIterator valid() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function 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 valid() Function The ArrayIterator::valid() function is an inbuilt function in PHP which is used to check whether an array contains more entries or not. Syntax: bool ArrayIterator::valid( void ) Parameters: This function does not accept any parameters. Return Value: This function returns TRUE if the iterator is vali 1 min read PHP | AppendIterator key() Function The AppendIterator::key() function is an inbuilt function in PHP which is used to return the current key. Syntax: scalar AppendIterator::key( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current key if it is valid or NULL otherwise. Below p 2 min read PHP | AppendIterator next() Function The AppendIterator::next() function is an inbuilt function in PHP which is used to move the element into the next element. Syntax: void AppendIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustr 2 min read PHP | ArrayIterator append() Function The ArrayIterator::append() function is an inbuilt function in PHP which is used to append an element into an array iterator. Syntax: void ArrayIterator::append( mixed $value ) Parameters: This function accepts single parameter $value that holds the value that need to be append. Return Value: This f 1 min read PHP | AppendIterator append() Function The AppendIterator::append() function is an inbuilt function in PHP which is used to append an iterator. Syntax: void AppendIterator::append( Iterator $iterator ) Parameters: This function accepts single parameter $iterator which holds the iterator to append. Return Value: This function does not ret 1 min read PHP | DirectoryIterator valid() Function The DirectoryIterator::valid() function is an inbuilt function in PHP which is used to check the current DirectoryIterator position is a valid file or not. Syntax: bool DirectoryIterator::valid( void ) Parameters: This function does not accept any parameters. Return Value: This function returns TRUE 1 min read 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 | AppendIterator __construct() Function The AppendIterator::__construct() function is an inbuilt function in PHP which is used to construct an AppendIterator. Syntax: public AppendIterator::__construct( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs il 2 min read PHP | ArrayIterator serialize() Function The ArrayIterator::serialize() function is an inbuilt function in PHP which is used to serialize the array iterator. Syntax: string ArrayIterator::serialize( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the serialized ArrayIterator. Below progr 1 min read Like