Change language

PHP ArrayIterator getArrayCopy () function

Syntax:
array ArrayIterator::getArrayCopy (void)
Parameters:This function takes no parameters.Returned value:This function returns a copy of the array.The following programs illustrate the ArrayIterator function: : getArrayCopy() in PHP:Program 1:  
// Declare ArrayIterator $arrItr = new ArrayIterator ( array ( ’G’ , ’ e’ , ’e’ , ’ k’ , ’s’ , ’ f’ , ’o’ , ’r’ ) );  
// Create a copy of the array $copyArr = $arrItr -> getArrayCopy();  
// Display the iterator array element var_dump ( $copyArr );  
?>
Exit:
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:  
// Declare ArrayIterator $arrItr = new ArrayIterator ( array ( "Geeks" , "for" , "Geeks" ) );  
// Add item to array $arrItr -> append ( "Computer" ); $arrItr -> append ( "Science" ); $arrItr -> append ( "Portal" );  
// Create a copy of the iterator array $copyArr = $arrItr -> getArrayCopy();  
// Show array element var_dump ( $copyArr );  
?>
Exit:
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"}
Link: https://www.php.net/manual/en/arrayiterator.getarraycopy.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method