PHP 8.4.0 RC4 available for testing

Ds\Sequence::contains

(PECL ds >= 1.0.0)

Ds\Sequence::containsDetermines if the sequence contains given values

说明

abstract public Ds\Sequence::contains(mixed ...$values): bool

Determines if the sequence contains all values.

参数

values

Values to check.

返回值

false if any of the provided values are not in the sequence, true otherwise.

示例

示例 #1 Ds\Sequence::contains() example

<?php
$sequence
= new \Ds\Vector(['a', 'b', 'c', 1, 2, 3]);

var_dump($sequence->contains('a')); // true
var_dump($sequence->contains('a', 'b')); // true
var_dump($sequence->contains('c', 'd')); // false

var_dump($sequence->contains(...['c', 'b', 'a'])); // true

// Always strict
var_dump($sequence->contains(1)); // true
var_dump($sequence->contains('1')); // false

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

以上示例的输出类似于:

bool(true)
bool(true)
bool(false)
bool(true)
bool(true)
bool(false)
bool(true)
添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top