(PECL pthreads >= 2.0.0)
Manipulation
public boolean Threaded::merge ( mixed $from [, bool $overwrite ] )
Merges data into the current object
Parameters:
from
The data to merge
overwrite
Overwrite existing keys, by default true
Returns:
A boolean indication of success
Examples:
Merging into the property table of a threaded object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?php $array = []; while ( count ( $array ) < 10) $array [] = count ( $array ); $stdClass = new stdClass(); $stdClass ->foo = "foo" ; $stdClass ->bar = "bar" ; $stdClass ->baz = "baz" ; $safe = new Threaded(); $safe ->merge( $array ); $safe ->foo = "bar" ; $safe ->merge( $stdClass , false); var_dump( $safe ); ?> |
The above example will output:
object(Threaded)#2 (13) { ["0"]=> int(0) ["1"]=> int(1) ["2"]=> int(2) ["3"]=> int(3) ["4"]=> int(4) ["5"]=> int(5) ["6"]=> int(6) ["7"]=> int(7) ["8"]=> int(8) ["9"]=> int(9) ["foo"]=> string(3) "bar" ["bar"]=> string(3) "bar" ["baz"]=> string(3) "baz" }
Please login to continue.