array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'arrayobject.getarraycopy.php', 1 => 'ArrayObject::getArrayCopy', ), 'up' => array ( 0 => 'class.arrayobject.php', 1 => 'ArrayObject', ), 'prev' => array ( 0 => 'arrayobject.exchangearray.php', 1 => 'ArrayObject::exchangeArray', ), 'next' => array ( 0 => 'arrayobject.getflags.php', 1 => 'ArrayObject::getFlags', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/arrayobject/getarraycopy.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
ArrayObject::getArrayCopy — Creates a copy of the ArrayObject
This function has no parameters.
Returns a copy of the array. When the ArrayObject refers to an object, an array of the properties of that object will be returned.
Example #1 ArrayObject::getArrayCopy() example
<?php
// Array of available fruits
$fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10);
$fruitsArrayObject = new ArrayObject($fruits);
$fruitsArrayObject['pears'] = 4;
// create a copy of the array
$copy = $fruitsArrayObject->getArrayCopy();
print_r($copy);
?>
The above example will output:
Array ( [lemons] => 1 [oranges] => 4 [bananas] => 5 [apples] => 10 [pears] => 4 )