Syntax:void SplObjectStorage::addAll ($value)
Parameters: This function takes one parameter, $value,which contains the store to be imported.Return value:returns no value.The programs below illustrate the function SplObjectStorage::addAll()in PHP:Program 1:
// Declaring an empty std class
$obj
=
new
StdClass;
// Declare empty SplObjectStorage
$gfg
=
new
SplObjectStorage();
$gfg
[
$obj
] =
" GeeksforGeeks " ;
$gfg1
=
new
SplObjectStorage();
$gfg1
-> addAll (
$gfg
);
// Print the result added to the storage object
echo
$gfg1
[
$obj
].
""
;
?>
Exit:GeeksforGeeks
Program 2:
// Declare an empty std class
$obj
=
new
StdClass;
$obj2
=
new
StdClass;
// Declare empty SplObjectStorage
$gfg
=
new
SplObjectStorage();
$gfg
[
$obj
] =
"GeeksforGeeks"
;
$gfg
[
$obj2
] =
"GeeksforGeeks2"
;
$gfg1
=
new
SplObjectStorage();
$gfg1
-> addAll (
$gfg
);
// Print the result with the entire object
print_r (
$gfg1
);
?>
Exit:SplObjectStorage Object ( [storage: SplObjectStorage: private] = > Array ([00000000219a7b260000000055def3bf] = > Array ([obj] = > stdClass Object() [inf] = > GeeksforGeeks) [00000000219a7b250000000055def3b] > stdClass Object() [inf] = > GeeksforGeeks2)))
Link: https://www.php.net/manual/en/splobjectstorage.addall.php