略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Ds\Map::diff

2024-04-30

Ds\Map::diff

(PECL ds >= 1.0.0)

Ds\Map::diffCreates a new map using keys that aren't in another map

说明

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

Returns the result of removing all keys from the current instance that are present in a given map.

A \ B = {x ∈ A | x ∉ B}

参数

map

The map containing the keys to exclude in the resulting map.

返回值

The result of removing all keys from the current instance that are present in a given map.

See Also

范例

示例 #1 Ds\Map::diff() 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->diff($b));
?>

以上例程的输出类似于:

object(Ds\Map)#3 (1) {
  [0]=>
  object(Ds\Pair)#4 (2) {
    ["key"]=>
    string(1) "a"
    ["value"]=>
    int(1)
  }
}
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/ds-map.diff.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3