SplObjectStorage::removeAll

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SplObjectStorage::removeAll別のストレージに含まれているオブジェクトを現在のストレージから取り除く

説明

public SplObjectStorage::removeAll(SplObjectStorage $storage): int

別のストレージに含まれているオブジェクトを現在のストレージから取り除きます。

パラメータ

storage

取り除きたい要素を含むストレージ。

戻り値

取り除かれた後に残ったオブジェクトの数を返します。

例1 SplObjectStorage::removeAll() の例

<?php
$o1
= new stdClass;
$o2 = new stdClass;
$a = new SplObjectStorage();
$a[$o1] = "foo";

$b = new SplObjectStorage();
$b[$o1] = "bar";
$b[$o2] = "gee";

var_dump(count($b));
$b->removeAll($a);
var_dump(count($b));
?>

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

int(2)
int(1)

参考

add a note add a note

User Contributed Notes 1 note

up
8
rafal dot wrzeszcz at wrzasq dot pl
10 years ago
You can call:

$storage->removeAll($storage);

To remove all elements.
To Top