(PECL pht >= 0.0.1)
pht\Vector::resize — Resizes a vector
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.
sizeThe new size of the vector.
valueThe value to initialise the empty vector slots to (only used if the vector is enlarged).
No return value.
Exemplo #1 Resizing a vector
<?php
use pht\Vector;
$vector = new Vector(1);
var_dump($vector);
$vector->resize(2, 1);
var_dump($vector);
$vector->resize(1, 2); // unused second arg
var_dump($vector);
O exemplo acima irá imprimir:
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)
}