The SplObjectStorage classIntroductionThe SplObjectStorage class provides a map from objects to data or, by ignoring data, an object set. This dual purpose can be useful in many cases involving the need to uniquely identify objects. Class synopsis
SplObjectStorage
implements
Countable
Iterator
Serializable
ArrayAccess
/* Methods */
public int addAll(SplObjectStorage
$storage )public void attach(object
$object , mixed $info = null )public bool contains(object
$object )public int count(int
$mode = COUNT_NORMAL )public object current()
public void detach(object
$object )public string getHash(object
$object )public mixed getInfo()
public int key()
public void next()
public bool offsetExists(object
$object )public mixed offsetGet(object
$object )public void offsetSet(object
$object , mixed $info = null )public void offsetUnset(object
$object )public int removeAll(SplObjectStorage
$storage )public int removeAllExcept(SplObjectStorage
$storage )public void rewind()
public string serialize()
public void setInfo(mixed
$info )public void unserialize(string
$data )public bool valid()
Examples
Example #1 SplObjectStorage as a set
The above example will output: bool(true) bool(true) bool(false) bool(true) bool(false) bool(false) Example #2 SplObjectStorage as a map
The above example will output: array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
|