<?php
// Array de frutas
$fruits = array("limones" => 1, "naranjas" => 4, "bananas" => 5, "manzanas" => 10);
// Array de lugares en Europa
$locations = array('Amsterdam', 'Paris', 'London');
$fruitsArrayObject = new ArrayObject($fruits);
// Now exchange fruits for locations
$old = $fruitsArrayObject->exchangeArray($locations);
print_r($old);
print_r($fruitsArrayObject);
?>
El resultado del ejemplo sería:
Array
(
[limones] => 1
[naranjas] => 4
[bananas] => 5
[manzanas] => 10
)
ArrayObject Object
(
[0] => Amsterdam
[1] => Paris
[2] => London
)