PHP官方手册 - 让我们略微加速

PHP - Manual: pht\Vector::push (官方文档)

更新于:2019-08-18 (43阅读)

pht\Vector::push

(PECL pht >= 0.0.1)

pht\Vector::pushPushes a value to the vector

说明

public pht\Vector::push ( mixed $value ) : void

This method pushes a value onto the end of a vector (in constant time). The vector will automatically be resized if it is not large enough.

Since the pht\Vector class supports array access, new values can also be pushed onto the vector using the empty subset notation ([]).

参数

value

The value to be pushed onto the end of the vector. This value will be serialised (since it may be passed around between threads).

返回值

No return value.

范例

Example #1 Pushing values to a vector

<?php

use pht\Vector;

$vector = new Vector();

$vector->push(1);
$vector[] = 2;

var_dump($vector);

以上例程会输出:

object(pht\Vector)#1 (2) {
  [0]=>
  int(1)
  [1]=>
  int(2)
}
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/pht-vector.push.php

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