Php/docs/threaded.merge
来自菜鸟教程
Threaded::merge
(PECL pthreads >= 2.0.0)
Threaded::merge — 操作
参数
from
- 要合并的数据
overwrite
- 如果现有对象已经存在同键的数据,是否覆盖。默认为 true
返回值
布尔值,表示操作是否成功
范例
Example #1 合并数据到对象的属性表
<?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->merge($stdClass);var_dump($safe);?>
以上例程会输出:
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) "foo" ["bar"]=> string(3) "bar" ["baz"]=> string(3) "baz" }