Threaded::merge
(PECL pthreads >= 2.0.0)
Threaded::merge — Manipulation
Описание
Merges data into the current object
Список параметров
-
from
-
The data to merge
-
overwrite
-
Overwrite existing keys, by default true
Возвращаемые значения
A boolean indication of success
Примеры
Пример #1 Merging into the property table of a threaded object
<?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" }
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для управления процессами программ
- pthreads
- Функция Threaded::chunk() - Manipulation
- Функция Threaded::count() - Manipulation
- Threaded::extend
- Threaded::from
- Функция Threaded::getTerminationInfo() - Error Detection
- Функция Threaded::isRunning() - State Detection
- Функция Threaded::isTerminated() - State Detection
- Функция Threaded::isWaiting() - State Detection
- Функция Threaded::lock() - Synchronization
- Функция Threaded::merge() - Manipulation
- Функция Threaded::notify() - Synchronization
- Функция Threaded::pop() - Manipulation
- Функция Threaded::run() - Execution
- Функция Threaded::shift() - Manipulation
- Функция Threaded::synchronized() - Synchronization
- Функция Threaded::unlock() - Synchronization
- Функция Threaded::wait() - Synchronization
Коментарии
The example output is different on my side:
<?php
/*
object(Threaded)#2 (11) {
["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"
}
*/
?>
for
windows using
PHP_VERSION 5.6.11
php_pthreads-2.0.10-5.6-ts-vc11-x86.zip @ http://windows.php.net/downloads/pecl/releases/pthreads/2.0.10/
and
linux using
PHP_VERSION 5.6.10-1~dotdeb+zts+7.3
So $stdClass wont be merged.