PHP | ArrayObjects::_construct() Function Last Updated : 17 Apr, 2018 Comments Improve Suggest changes Like Article Like Report 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 three parameters as shown in the above syntax and are described below: $input: This parameter is used to accept input as an array or an object. $flags: Flags are used to control the behaviour of the Arrayobject. $iterator_class: It is used to specify the class that will be used for the iteration of the ArrayObject Object. Return Value: This function returns an ArrayObject on successful compilation. Errors and Exceptions: If $input is not an array or an object the compiler will show an error. If $flags set are not having integer values then the compiler will show an error message. Below programs illustrate the ArrayObjects::_construct() function: Program 1: PHP <?php $array = array('1' => 'one', '2' => 'two', '3' => 'three'); $arrayobject = new ArrayObject($array); var_dump($arrayobject); ?> Output: object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(3) { [1]=> string(3) "one" [2]=> string(3) "two" [3]=> string(5) "three" } } Program 2: PHP <?php $array = array('1' => 'Geeks', '2' => 'for', '3' => 'Geeks'); $arrayobject = new ArrayObject($array); var_dump($arrayobject); ?> Output: object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(3) { [1]=> string(5) "Geeks" [2]=> string(3) "for" [3]=> string(5) "Geeks" } } Reference: http://php.net/manual/en/arrayobject.construct.php Comment More infoAdvertise with us Next Article PHP | ArrayObjects::_construct() Function O oindrilaray Follow Improve Article Tags : Web Technologies PHP Similar Reads PHP | ArrayObject count() Function The ArrayObject::count() function is an inbuilt function in PHP which is used to get the number of public properties in the ArrayObject. Syntax: int ArrayObject::count( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the number of public propertie 1 min read PHP ArrayIterator __construct() Function 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 paramet 1 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 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 | 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 ArrayObject exchangeArray() function in PHP The exchangeArray() function of the ArrayObject class in PHP is used to exchange an array from an ArrayObject. That is, it replaces existing array from an ArrayObject with a newly described array. Syntax: ArrayObject exchangeArray( $inputArray ) Parameters: This function accepts a single parameter $ 2 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 ArrayObject setFlags() Function The ArrayObject::setFlags() function is an inbuilt function in PHP that is used to set the flag to change the behavior of the ArrayObject. Syntax: void ArrayObject::setFlags( int $flags ) Parameters: This function accepts single parameter $flags which hold the behavior of new ArrayObject. This param 2 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 Like