略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Threaded::chunk

2024-04-29

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 noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/threaded.chunk.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3