array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'arrayobject.exchangearray.php', 1 => 'ArrayObject::exchangeArray', 2 => 'Exchange the array for another one', ), 'up' => array ( 0 => 'class.arrayobject.php', 1 => 'ArrayObject', ), 'prev' => array ( 0 => 'arrayobject.count.php', 1 => 'ArrayObject::count', ), 'next' => array ( 0 => 'arrayobject.getarraycopy.php', 1 => 'ArrayObject::getArrayCopy', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/arrayobject/exchangearray.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
ArrayObject::exchangeArray — Exchange the array for another one
Returns the old array.
Örnek 1 ArrayObject::exchangeArray() example
<?php
// Array of available fruits
$fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10);
// Array of locations in Europe
$locations = array('Amsterdam', 'Paris', 'London');
$fruitsArrayObject = new ArrayObject($fruits);
// Now exchange fruits for locations
$old = $fruitsArrayObject->exchangeArray($locations);
var_dump($old);
var_dump($fruitsArrayObject);
?>Yukarıdaki örneğin çıktısı:
array(4) {
["lemons"]=>
int(1)
["oranges"]=>
int(4)
["bananas"]=>
int(5)
["apples"]=>
int(10)
}
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(3) {
[0]=>
string(9) "Amsterdam"
[1]=>
string(5) "Paris"
[2]=>
string(6) "London"
}
}