PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

Ds\Map::intersect - Creates a new map by intersecting keys with another map. | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

Ds\Map::intersect

(PECL ds >= 1.0.0)

Ds\Map::intersectCreates a new map by intersecting keys with another map.

説明

public Ds\Map Ds\Map::intersect ( Ds\Map $map )

Creates a new map containing the pairs of the current instance whose keys are also present in the given map. In other words, returns a copy of the current instance with all keys removed that are not also in the other map.

A ∩ B = {x : x ∈ A ∧ x ∈ B}

注意:

Values from the current instance will be kept.

パラメータ

map

The other map, containing the keys to intersect with.

返り値

The key intersection of the current instance and another map.

See Also

例1 Ds\Map::intersect() example

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

var_dump($a->intersect($b));
?>

上の例の出力は、 たとえば以下のようになります。

object(Ds\Map)#3 (2) {
  [0]=>
  object(Ds\Pair)#4 (2) {
    ["key"]=>
    string(1) "b"
    ["value"]=>
    int(2)
  }
  [1]=>
  object(Ds\Pair)#5 (2) {
    ["key"]=>
    string(1) "c"
    ["value"]=>
    int(3)
  }
}

忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「Ds\Map::intersect - Creates a new map by intersecting keys with another map.」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | Ds\Map::intersect - Creates a new map by intersecting keys with another map.」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: