PHP 8.0.3 Released!


(PHP 5, PHP 7)

ArrayIterator::getArrayCopyRécupère la copie d'un tableau


public ArrayIterator::getArrayCopy ( ) : array

Récupère la copie d'un tableau.


Cette fonction est actuellement non documentée ; seule la liste des arguments est disponible.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Une copie d'un tableau, ou un tableau de propriétés publiques si ArrayIterator se réfère à un objet.

Voir aussi

add a note add a note

User Contributed Notes 2 notes

lenye01 at gmail dot com
10 years ago
the difference of this method and the direct assign the object to a value is as follows:

= array('name'=>'mengzhi','age'=>'12','city'=>'shanghai');
$a = new ArrayIterator($b);
$c = $a->getArrayCopy();
object(ArrayIterator)#1 (1) { ["storage":"ArrayIterator":private]=> array(4) { ["name"]=> string(7) "mengzhi" ["age"]=> string(2) "12" ["city"]=> string(8) "shanghai" [0]=> array(2) { ["home"]=> string(5) "china" ["work"]=> string(9) "developer" } } }

array(4) { ["name"]=> string(7) "mengzhi" ["age"]=> string(2) "12" ["city"]=> string(8) "shanghai" [0]=> array(2) { ["home"]=> string(5) "china" ["work"]=> string(9) "developer" } }
irvine L
3 years ago
Just in case some of you out there do NOT know this:

(a). 'getArrayCopy()', returns a copy of the ORIGINAL array - iterator object. Therefore, using (for example) 'LimitIterator' on an array-object, and then calling 'getArrayCopy' afterwards, might not return the current (adjusted) object.

(b). Instead, use the 'iterator_to_array' function, in order to access, or return, the current state of the array-object-iterator (whatever). Using the example above (in '(a)'); passing the 'LimitIterator' object into 'iterator_to_array', should return the CURRENT, and NOT ORIGINAL state of your array (iterator object).
To Top