Threaded::chunk

(PECL pthreads >= 2.0.0)

Threaded::chunk操作

说明

public Threaded::chunk(int $size, bool $preserve): array

获取给定数量的对象属性表,可以选择是否保留键名称。

参数

size

要获取的条目数量

preserve

保留成员原有的键名称,默认为 false

返回值

数组对象,包含从对象属性表中返回的给定数量的条目。

示例

示例 #1 获取对象属性表中的部分条目

<?php
$safe
= new Threaded();

while (
count($safe) < 10) {
$safe[] = count($safe);
}

var_dump($safe->chunk(5));
?>

以上示例会输出:

array(5) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
}

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top