array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'splobjectstorage.removeallexcept.php', 1 => 'SplObjectStorage::removeAllExcept', 2 => 'Removes all objects except for those contained in another storage from the current storage', ), 'up' => array ( 0 => 'class.splobjectstorage.php', 1 => 'SplObjectStorage', ), 'prev' => array ( 0 => 'splobjectstorage.removeall.php', 1 => 'SplObjectStorage::removeAll', ), 'next' => array ( 0 => 'splobjectstorage.rewind.php', 1 => 'SplObjectStorage::rewind', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/splobjectstorage/removeallexcept.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

SplObjectStorage::removeAllExcept

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

SplObjectStorage::removeAllExceptRemoves all objects except for those contained in another storage from the current storage

Beschreibung

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

Removes all objects except for those contained in another storage from the current storage.

Parameter-Liste

storage

The storage containing the elements to retain in the current storage.

Rückgabewerte

Returns the number of remaining objects.

Beispiele

Beispiel #1 SplObjectStorage::removeAllExcept() example

<?php
$a
= (object) 'a';
$b = (object) 'b';
$c = (object) 'c';

$foo = new SplObjectStorage;
$foo->attach($a);
$foo->attach($b);

$bar = new SplObjectStorage;
$bar->attach($b);
$bar->attach($c);

$foo->removeAllExcept($bar);
var_dump($foo->contains($a));
var_dump($foo->contains($b));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

bool(false)
bool(true)