+

ArrayObject getIteratorClass () Function in PHP

Syntax :
string getIteratorClass()
Parameters : This function takes no parameters.Return Value : This function returns the name of the iterator class for this ArrayObject.The following programs illustrate the above function:Program 1 : < tr>
// PHP program for illustration
// getIteratorClass() function $arr = array ( "a" = > "engineer" , "b" = > "are" , "c" = > "awesome" );  
// Create array object $arrObject = new ArrayObject ( $arr );  
// Retrieve the name of the iterator class $itrClassName = $arrObject -> getIteratorClass();  
// Print the name of the iterator class print ( $itrClassName );  
?>
Exit:
ArrayIterator  Program 2 :      
// PHP illustration program
// getIteratorClass() function 
// Create a custom integrator class SampleIterator extends ArrayIterator {  
} $arr = array ( "a" = > "engineer" , "b" = > "are" , "c" = > "awesome" );  
// Create array object $arrObject = new ArrayObject ( $arr );  
// Install a new iterator $arrObject -> setIteratorClass ( `SampleIterator` );  
// Retrieve the name of the iterator class $itrClassName = $arrObject -> getIteratorClass();  
// Print the name of the iterator class print ( $itrClassName );  
?>
Exit:
SampleIterator  Link :  http://php.net/ manual / en / arrayobject.getiteratorclass.php                                        
             
                
Get Solution for free from DataCamp guru