array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'ds-set.copy.php', 1 => 'Ds\\Set::copy', 2 => 'Returns a shallow copy of the set', ), 'up' => array ( 0 => 'class.ds-set.php', 1 => 'Ds\\Set', ), 'prev' => array ( 0 => 'ds-set.contains.php', 1 => 'Ds\\Set::contains', ), 'next' => array ( 0 => 'ds-set.count.php', 1 => 'Ds\\Set::count', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ds/ds/set/copy.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

Ds\Set::copy

(PECL ds >= 1.0.0)

Ds\Set::copyReturns a shallow copy of the set

Descrizione

public Ds\Set::copy(): Ds\Set

Returns a shallow copy of the set.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

Returns a shallow copy of the set.

Esempi

Example #1 Ds\Set::copy() example

<?php
$a
= new \Ds\Set([1, 2, 3]);
$b = $a->copy();

// Updating the copy doesn't affect the original
$b->add(4);

print_r($a);
print_r($b);
?>

Il precedente esempio visualizzerĂ  qualcosa simile a:

Ds\Set Object
(
    [0] => 1
    [1] => 2
    [2] => 3
)
Ds\Set Object
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
)