Syntax :
array getArrayCopy()
Parameters : This function takes no parameters.
Return Value : This function returns an array that is a copy of the array in this ArrayObject.The following programs illustrate the above function:
Program 1 :
< tbody>
// PHP program for illustrations
// getArrayCopy() function
$arr
=
array
(
" a "
= >
" engineer " ,
"b"
= >
"are"
,
"c"
= >
"awesome"
);
// Create array object
$arrObject
=
new
ArrayObject (
$arr
);
// Create a copy of the array
$copyArr
=
$arrObject
-> getArrayCopy();
print_r (
$copyArr
);
?>
Exit:Array ([ a] = > engineer [b] = > are = > awesome)
Program 2 :
// PHP illustration program
// getArrayCopy function()
$arr
=
array
(
"a"
= >
"Welcome"
,
" b "
= >
" 2 "
,
"d"
= >
"GFG"
);
// Create array object
$arrObject
=
new
ArrayObject (
$arr
);
// Create a copy of the array
$copyArr
=
$arrObject
-> getArrayCopy();
print_r (
$copyArr
);
?>
Exit:Array ([ a] = > Welcome [b] = > 2 [d] = > GFG)
Link : http://php.net/manual/en/arrayobject.exchangearray.php