略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: pht\Vector::resize

2024-04-26

pht\Vector::resize

(PECL pht >= 0.0.1)

pht\Vector::resizeResizes a vector

说明

public pht\Vector::resize ( int $size [, mixed $value = 0 ] ) : void

Resizes the vector. If it is enlarged, then the value parameter will be used to fill in the new slots. If it is made smaller, then the end values will be truncated.

参数

size

The new size of the vector.

value

The value to initialise the empty vector slots to (only used if the vector is enlarged).

返回值

No return value.

范例

Example #1 Resizing a vector

<?php

use pht\Vector;

$vector = new Vector(1);
var_dump($vector);
$vector->resize(21);
var_dump($vector);
$vector->resize(12); // unused second arg
var_dump($vector);

以上例程会输出:

object(pht\Vector)#1 (1) {
  [0]=>
  int(0)
}
object(pht\Vector)#1 (2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
object(pht\Vector)#1 (1) {
  [0]=>
  int(0)
}
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.resize.php

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