PHP | ArrayIterator getArrayCopy() Function Last Updated : 21 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The ArrayIterator::getArrayCopy() function is an inbuilt function in PHP which is used to create a copy of an array. Syntax: array ArrayIterator::getArrayCopy( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the copy of array. Below programs illustrate the ArrayIterator::getArrayCopy() function in PHP: Program 1: php <?php // Declare an ArrayIterator $arrItr = new ArrayIterator( array('G', 'e', 'e', 'k', 's', 'f', 'o', 'r') ); // Create a copy of array $copyArr = $arrItr->getArrayCopy(); // Display the array iterator element var_dump($copyArr); ?> Output: array(8) { [0]=> string(1) "G" [1]=> string(1) "e" [2]=> string(1) "e" [3]=> string(1) "k" [4]=> string(1) "s" [5]=> string(1) "f" [6]=> string(1) "o" [7]=> string(1) "r" } Program 2: php <?php // Declare an ArrayIterator $arrItr = new ArrayIterator( array("Geeks", "for", "Geeks") ); // Append the element into array $arrItr->append("Computer"); $arrItr->append("Science"); $arrItr->append("Portal"); // Create copy of array iterator $copyArr = $arrItr->getArrayCopy(); // Display the array element var_dump($copyArr); ?> Output: array(6) { [0]=> string(5) "Geeks" [1]=> string(3) "for" [2]=> string(5) "Geeks" [3]=> string(8) "Computer" [4]=> string(7) "Science" [5]=> string(6) "Portal" } Reference: https://www.php.net/manual/en/arrayiterator.getarraycopy.php Comment More infoAdvertise with us Next Article PHP | ArrayIterator getArrayCopy() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads 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 | ArrayIterator getFlags() Function The ArrayIterator::getFlags() function is an inbuilt function in PHP which is used to get the behavior of flags of array iterator. Syntax: int ArrayIterator::getFlags( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the behavior flags of the Array 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 next() Function 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 t 1 min read PHP | ArrayIterator offsetGet() Function The ArrayIterator::offsetGet() function is an inbuilt function in PHP which is used to get the value of an offset. Syntax: mixed ArrayIterator::offsetGet( mixed $index ) Parameters: This function accepts single parameter $index which holds the offset to get the value from. Return Value: This functio 1 min read PHP | ArrayIterator ksort() Function The ArrayIterator::ksort() function is an inbuilt function in PHP which is used to sort the array element by key. Syntax: void ArrayIterator::ksort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the A 2 min read PHP | ArrayIterator natsort() Function The ArrayIterator::natsort() function is an inbuilt function in PHP which is used to sort an array naturally. Syntax: void ArrayIterator::natsort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the Arr 1 min read PHP | ArrayIterator offsetSet() Function The ArrayIterator::offsetSet() function is an inbuilt function in PHP which is used to set the value for an offset. Syntax: void ArrayIterator::offsetSet( mixed $index, mixed $newval ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter hol 2 min read PHP | ArrayIterator offsetUnset() Function The ArrayIterator::offsetUnset() function is an inbuilt function in PHP which is used to unset the value for an offset. Syntax: void ArrayIterator::offsetUnset( mixed $index ) Parameters: This function accepts single parameter $index which holds the index to unset the offset. Return Value: This func 2 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