Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: pht\Vector::unshift - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: pht\Vector::unshift

2025-08-02

pht\Vector::unshift

(PECL pht >= 0.0.1)

pht\Vector::unshiftUnshifts a value to the vector front

说明

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

This method unshifts a value to the front of a vector (in linear time). The vector will automatically be resized if it is not large enough.

参数

value

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

返回值

No return value.

范例

Example #1 Unshifting a value to the front of a vector

<?php

use pht\Vector;

$vector = new Vector();

for (
$i 0$i 3; ++$i) {
    
$vector->unshift($i); // causes a quadratic runtime, beware
}

var_dump($vector);

以上例程会输出:

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

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