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

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

更新于:2019-12-04 (114阅读)

pht\Vector::deleteAt

(PECL pht >= 0.0.1)

pht\Vector::deleteAtDeletes a value in the vector

说明

public pht\Vector::deleteAt ( int $offset ) : void

This method deletes a value at the specified offset in the vector (in linear time).

Since the pht\Vector class supports array access, deleting values can also be performed using the array subset notation ([]) in combination with the unset() function.

参数

offset

The offset at which the value will be deleted at. This offset must be within the 0..(N-1) range (inclusive), where N is the size of the vector. Attempting to delete at offsets outside of this range will result in an Error exception.

返回值

No return value.

范例

Example #1 Deleting values in a vector

<?php

use pht\Vector;

$vector = new Vector();

$vector[] = 1;
$vector[] = 2;
$vector[] = 3;
$vector[] = 4;

$vector->deleteAt(1);
unset(
$vector[1]);

var_dump($vector);

以上例程会输出:

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

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