ArrayObject::getArrayCopy


Creates a copy of the ArrayObject.



<?php

arr 
public ArrayObject::getArrayCopy void )

?>

 ATTENTION 


Exports the ArrayObject to an ARRAY.

When the ArrayObject refers to an object, an ARRAY of the public properties of that object will be returned.



  1 EXERCISE   

<?php

$Dwarfs 
= [ => 'Bashful'=> 'Doc'
                   
=> 'Grumpy'=> 'Happy'
                   
=> 'Sneezy'=> 'Sleepy'=> 'Dopey'];

$dwArrayObject = new ArrayObject($Dwarfs);

$dwcopy $dwArrayObject->getArrayCopy();

foreach(
$dwcopy as $dw => $dwc)
{
var_dump($dw$dwc);
echo 
'<br>';
}

?>

 RESULT   

int(1) string(7) "Bashful"
int(2) string(3) "Doc"
int(3) string(6) "Grumpy"
int(4) string(5) "Happy"
int(5) string(6) "Sneezy"
int(6) string(6) "Sleepy"
int(7) string(5) "Dopey"


  2 EXERCISE   

<?php

$Dwarfs 
= [ => 'Bashful'=> 'Doc'
                   
=> 'Grumpy'=> 'Happy'
                   
=> 'Sneezy'=> 'Sleepy'=> 'Dopey'];

$dwArrayObject = new ArrayObject($Dwarfs);

$dwArrayObject['Snow White'] = 8;

$dwcopy $dwArrayObject->getArrayCopy();

foreach(
$dwcopy as $dw => $dwc)
{
var_dump($dw$dwc);
echo 
'<br>';
}

?>

 RESULT   

string(7) "Bashful" int(1)
string(3) "Doc" int(2)
string(6) "Grumpy" int(3)
string(5) "Happy" int(4)
string(6) "Sneezy" int(5)
string(6) "Sleepy" int(6)
string(5) "Dopey" int(7)
string(10) "Snow White" int(8)