PHP ArrayIterator __construct() Function Last Updated : 27 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The ArrayIterator::__construct() function is an inbuilt function in PHP which is used to construct an ArrayIterator. Syntax: public ArrayIterator::__construct( mixed $array, int $flags = 0 ) Parameters: This function accepts two parameters as mentioned above and described below: $array: This parameter holds the array or array of object iterator.$flag: This parameter holds the flat to control the behavior of the ArrayIterator object. Return Value: This function returns the ArrayIterator object. Below programs illustrate the ArrayIterator::__construct() function in PHP: Program 1: php <?php // Declare an ArrayIterator $arrItr = new ArrayIterator( array('G', 'e', 'e', 'k', 's', 'f', 'o', 'r'), ArrayIterator::ARRAY_AS_PROPS ); // Display the elements while($arrItr->valid()) { echo $arrItr->current(); $arrItr->next(); } ?> Output:Geeksfor Program 2: php <?php // Declare an ArrayIterator $arrItr = new ArrayIterator( array("Geeks", "for", "Geeks"), ArrayIterator::STD_PROP_LIST ); // Display the elements foreach ($arrItr as $key => $val) { echo $key . " => " . $val . "\n"; } ?> Output:0 => Geeks 1 => for 2 => Geeks Reference: https://www.php.net/manual/en/arrayiterator.construct.php Comment More infoAdvertise with us Next Article PHP ArrayIterator __construct() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | ArrayIterator count() Function The ArrayIterator::count() function is an inbuilt function in PHP which is used to count the elements of array iterator.Syntax: int ArrayIterator::count( void ) Parameters: This function does not accept any parameters.Return Value: This function returns the number of element present in the array ite 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 asort() Function The ArrayIterator::asort() function is an inbuilt function in PHP which is used to sort the array values. Syntax: void ArrayIterator::asort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the ArrayIter 1 min read PHP | CachingIterator __construct() Function The CachingIterator::__construct() function is an inbuilt function in PHP which is used to construct a new CachingIterator object for the iterator. Syntax: public CachingIterator::__construct( Iterator $iterator, int $flags = self::CALL_TOSTRING ) Parameters: This function accepts two parameters as 2 min read PHP | ArrayIterator current() Function The ArrayIterator::current() function is an inbuilt function in PHP which is used to return the current element of array iterator. Syntax: mixed ArrayIterator::current( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current element of array. 1 min read PHP | ArrayObjects::_construct() Function The ArrayObjects class allows objects to work as arrays. The ArrayObjects::_construct() is an in built PHP function to construct a new array object. Syntax: public ArrayObject::__construct ($input = array(), int $flags = 0, string $iterator_class = "ArrayIterator") Parameters: This function accepts 2 min read PHP | Collator __construct() Function The Collator::__construct() function is an inbuilt function in PHP which is used to create a new instance of Collator. Syntax: public Collator::__construct( string $locale ) Parameters: This function accepts single parameter $locale which holds the collation rules. If a null value is passed for the 1 min read PHP | ArrayIterator key() Function The ArrayIterator::key() function is an inbuilt function in PHP which returns the current key of the array element. Syntax: mixed ArrayIterator::key( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current array key. Below programs illustrate 1 min read PHP | ArrayIterator seek() Function The ArrayIterator::seek() function is an inbuilt function in PHP which is used to seek the position of an array iterator. Syntax: void ArrayIterator::seek( int $position ) Parameters: This function accepts single parameter $position which holds the position to seek. Return Value: This function does 1 min read PHP | ArrayIterator seek() Function The ArrayIterator::seek() function is an inbuilt function in PHP which is used to seek the position of an array iterator. Syntax: void ArrayIterator::seek( int $position ) Parameters: This function accepts single parameter $position which holds the position to seek. Return Value: This function does 1 min read Like