PHP | ArrayIterator next() Function
Last Updated :
21 Nov, 2019
The ArrayIterator::next() function is an inbuilt function in PHP which is used to move the iterator to the next entry.
Syntax:
void ArrayIterator::next( void )
Parameters: This function does not accept any parameters.
Return Value: This function does not return any value.
Below programs illustrate the ArrayIterator::next() function in PHP:
Program 1:
<?php
$arrItr = new ArrayIterator(
array ( 'G' , 'e' , 'e' , 'k' , 's' , 'f' , 'o' , 'r' )
);
while ( $arrItr ->valid()) {
echo $arrItr ->current();
$arrItr ->next();
}
?>
|
Program 2:
<?php
$arrItr = new ArrayIterator(
array ( "Geeks" , "for" , "Geeks" )
);
echo $arrItr ->current() . "\n" ;
$arrItr ->next();
echo $arrItr ->current() . "\n" ;
$arrItr ->next();
echo $arrItr ->current();
?>
|
Reference: https://www.php.net/manual/en/arrayiterator.next.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...