ArrayObject getIterator() Function in PHP Last Updated : 22 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The getIterator() function of the ArrayObject class in PHP is used to create an iterator from an ArrayObject instance. This iterator can be used to iterate through the array of the respective ArrayObject. Syntax: ArrayIterator getIterator() Parameters: This function does not accepts any parameters. Return Value: This function returns an Iterator from an ArrayObject instance. Below programs illustrate the above function: Program 1: php <?php // PHP program to illustrate the // getIterator() function $arr = array("a" => "geeks", "b" => "are", "c" => "awesome"); // Create array object $arrObject = new ArrayObject($arr); // Create the iterator $itr = $arrObject->getIterator(); // Use iterator to traverse Array while($itr->valid()) { echo $itr->key().' => '.$itr->current()."\n"; $itr->next(); } ?> Output: a => geeks b => are c => awesome Program 2: php <?php // PHP program to illustrate the // getIterator() function $arr = array("a" => "Welcome", "b" => "2", "d" => "GFG"); // Create array object $arrObject = new ArrayObject($arr); // Create the iterator $itr = $arrObject->getIterator(); // Use iterator to traverse Array while($itr->valid()) { echo $itr->key().' => '.$itr->current()."\n"; $itr->next(); } ?> Output: a => Welcome b => 2 d => GFG Reference: http://php.net/manual/en/arrayobject.getiterator.php Comment More infoAdvertise with us Next Article ArrayObject getIterator() Function in PHP gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-array PHP-function PHP-ArrayObject +1 More Similar Reads ArrayObject getIteratorClass() Function in PHP The getIteratorClass() function of the ArrayObject class in PHP is used to get the classname of the iterator used to iterate over this ArrayObject. Syntax: string getIteratorClass() Parameters: This function does not accepts any parameters. Return Value: This function returns the iterator classname 1 min read ArrayObject getArrayCopy() Function in PHP The getArrayCopy() function of the ArrayObject class in PHP is used to create a copy of this ArrayObject. This function returns the copy of the array present in this ArrayObject. Syntax: array getArrayCopy() Parameters: This function does not accepts any parameters. Return Value: This function retur 1 min read PHP | ArrayObject getFlags() Function The ArrayObject::getFlags() function is an inbuilt function in PHP which is used to get the behavior of flags of the ArrayObject. Syntax: int ArrayObject::getFlags( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the behavior flags of the ArrayObj 2 min read PHP | ArrayObject setIteratorClass() Function The ArrayObject::setIteratorClass() function is an inbuilt function in PHP which is used to set the iterator classname for the ArrayObject. Syntax: void ArrayObject::setIteratorClass( string $iterator_class ) Parameters: This function accepts single parameter $iterator_class which holds the class na 2 min read PHP iterator_to_array() Function The iterator_to_array() function is an inbuilt function in PHP that is used to copy the iterator object (e.g. objects implementing the Iterator or IteratorAggregate interface) into an array. An iterator is an object that allows you to loop through a set of values one at a time without knowing the un 3 min read ArrayObject natcasesort() Function in PHP The natcasesort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject following a natural order case sensitive sorting algorithm. Natural ordering means to arrange the elements in a order a normal human being would do. Syntax: void natcasesort() Parameters: This 2 min read ArrayObject offsetGet() Function in PHP The offsetGet() function of the ArrayObject class in PHP is used to get the value present at a specific index at the ArrayObject. Syntax: mixed offsetGet($index) Parameters: This function accepts a single parameter $index for which corresponding value will be returned. Return Value: This function re 1 min read ArrayObject offsetSet() Function in PHP The offsetSet() function of the ArrayObject class in PHP is used to update the value present at a specific index in the ArrayObject. Syntax: void offsetSet($index, $val) Parameters: This function accepts two parameters $index and $val. This function updates the value present at the index, $index wit 1 min read PHP | AppendIterator getIteratorIndex() Function The AppendIterator::getIteratorIndex() function is an inbuilt function in PHP which is used to get the index of the current inner iterator. Syntax: int AppendIterator::getIteratorIndex( void ) Parameters: This function does not accept any parameters. Return Value: This function returns an integer va 2 min read ArrayObject asort() Function in PHP The asort() function of the ArrayObject class in PHP is used to sort all of the entries of the ArrayObject according to the values. The elements are arranged according to the values keeping the maintaining the association of the keys with the value. Syntax: void asort() Parameters: This function doe 1 min read Like