Ds\Set::contains

Ds\Set::contains

(PECL ds >= 1.0.0)

Ds\Set::containsDetermines if the set contains all values.

Description

public bool Ds\Set::contains ([ mixed $...values ] )

Determines if the set contains all values.

Note:

Values of type object are supported. If an object implements Ds\Hashable, equality will be determined by the object's equals function. If an object does not implement Ds\Hashable, objects must be references to the same instance to be considered equal.

Caution

All comparisons are strict (type and value).

Parameters

values

Values to check.

Return Values

FALSE if any of the provided values are not in the set, TRUE otherwise.

Examples

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

<?php
$set = new \Ds\Set([1, 2, 3]);

var_dump($set->contains(1));                // true
var_dump($set->contains(1, 2));             // true
var_dump($set->contains(...[1, 2]));        // true

var_dump($set->contains("1"));              // false
var_dump($set->contains(...[1, 2, 3, 4]));  // false

var_dump($set->contains(...[]));            // true
?>

The above example will output something similar to:

bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(true)

© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/ds-set.contains.php

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部