|
Ds\Map::putAssociates a key with a value Description
public void Ds\Map::put(mixed
$key , mixed $value )
Associates a
Caution
Be careful when using array syntax. Scalar keys will be coerced to
integers by the engine. For example, See Arrays. Parameters
Return ValuesNo value is returned. ExamplesExample #1 Ds\Map::put example
The above example will output something similar to: Ds\Map Object ( [0] => Ds\Pair Object ( [key] => a [value] => 1 ) [1] => Ds\Pair Object ( [key] => b [value] => 2 ) [2] => Ds\Pair Object ( [key] => c [value] => 3 ) ) Example #2 Ds\Map::put example using objects as keys
The above example will output something similar to: object(Ds\Map)#1 (5) { [0]=> object(Ds\Pair)#7 (2) { ["key"]=> object(ArrayIterator)#2 (1) { ["storage":"ArrayIterator":private]=> array(0) { } } ["value"]=> int(2) } [1]=> object(Ds\Pair)#8 (2) { ["key"]=> object(stdClass)#3 (0) { } ["value"]=> int(3) } [2]=> object(Ds\Pair)#9 (2) { ["key"]=> object(stdClass)#4 (0) { } ["value"]=> int(4) } [3]=> object(Ds\Pair)#10 (2) { ["key"]=> object(HashableObject)#5 (1) { ["value":"HashableObject":private]=> int(1) } ["value"]=> int(6) } [4]=> object(Ds\Pair)#11 (2) { ["key"]=> object(HashableObject)#6 (1) { ["value":"HashableObject":private]=> int(2) } ["value"]=> int(8) } } |