« Threaded::isTerminated
Threaded::notify »

Threaded::merge

(PECL pthreads >= 2.0.0)

Threaded::merge — Manipulation

説明

public function Threaded::merge(mixed $from, bool $overwrite = ?): bool

Merges data into the current object

パラメータ

from

The data to merge

overwrite

Overwrite existing keys, by default true

戻り値

成功した場合に true を、失敗した場合に false を返します。

例

例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->foo = "bar";
$safe->merge($stdClass, false);

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) "bar"
  ["bar"]=>
  string(3) "bar"
  ["baz"]=>
  string(3) "baz"
}
関連キーワード:
Threaded   merge   stdClass   safe   Manipulation   overwrite   count   isTerminated   notify   pthreads   mixed   Merges   current   Overwrite   existing   keys   default   成功   Merging   property   table   threaded   while   dump
関連する関数・ページ:
threaded.count   threaded.pop   threaded.shift   threaded.chunk   class.threaded   threaded.extend