Ds\Map::merge

(PECL ds >= 1.0.0)

Ds\Map::mergeReturns the result of adding all given associations

说明

public Ds\Map::merge ( mixed $values ) : Ds\Map

Returns the result of associating all keys of a given traversable object or array with their corresponding values, combined with the current instance.

Note:

Values of the current instance will be overwritten by those provided where keys are equal.

参数

values

A traversable object or an array.

返回值

The result of associating all keys of a given traversable object or array with their corresponding values, combined with the current instance.

Note:

The current instance won't be affected.

范例

Example #1 Ds\Map::merge() example

<?php
$map 
= new \Ds\Map(["a" => 1"b" => 2"c" => 3]);

print_r($map->merge(["a" => 10"e" => 50]));
?>

以上例程的输出类似于:

Ds\Map Object
(
    [0] => Ds\Pair Object
        (
            [key] => a
            [value] => 10
        )

    [1] => Ds\Pair Object
        (
            [key] => b
            [value] => 2
        )

    [2] => Ds\Pair Object
        (
            [key] => c
            [value] => 3
        )

    [3] => Ds\Pair Object
        (
            [key] => e
            [value] => 50
        )

)
相关文章
php domxpath evaluates the given xpath expression and returns a typed result if possiblephp deque returns the value at a given indexphp deque returns the result of adding all given values to the dequephp map returns the value for a given keyphp map returns the result of applying a callback to each valuephp map returns the result of adding all given associationsphp map returns a sequence containing all the pairs of the mapphp map returns the pair at a given positional indexphp map returns the sum of all values in the mapphp sequence returns the result of adding all given values to the sequencephp set returns the result of adding all given values to the setphp vector returns the result of adding all given values to the vectorphp vector returns the sum of all values in the vectorphp date/time 函数 returns associative array with detailed info about given datephp ibm db2 函数 returns a result set listing the columns and associated metadata for a tablephp gnupg 函数 returns an array with information about all keys that matches the given patternphp oci8 函数 returns the next child statement resource from a parent statement resource that has oracle database 12c implicit result setsphp socket 函数 queries the local side of the given socket which may either result in host/port or in a unix filesystem path dependent on its typephp sqlite 函数 executes a query against a given database and returns a result handlephp mongocursor advances the cursor to the next result and returns that result
关注编程学问公众号