Php/docs/splobjectstorage.removeall

提供:Dev Guides
< Php
移動先:案内検索

SplObjectStorage::removeAll

(PHP 5 >= 5.3.0, PHP 7)

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


説明

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

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


パラメータ

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)

参考