php8.5
Home/ Manual/ ds / pair/ Ds\Pair::copy

Ds\Pair::copy

PHP function Edit on GitHub ✎

Returns a shallow copy of the pair

Description

Ds\Pair::copy(): Ds\Pair

Returns a shallow copy of the pair.

Parameters Parameters

Return Values

Returns a shallow copy of the pair.

Examples

Ds\Pair::copy() example

php
<?php
$a = new \Ds\Pair("a", 1);
$b = $a->copy();

$a->key = "x";

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

The above example will output something similar to:

output
Ds\Pair Object
(
    [key] => x
    [value] => 1
)
Ds\Pair Object
(
    [key] => a
    [value] => 1
)

Source: reference/ds/ds/pair/copy.xml · from the official PHP manual (php/doc-en)