PHP 7.2.7 Released

pht\Vector::shift

(PECL pht >= 0.0.1)

pht\Vector::shiftShifts a value from the vector

Description

public mixed pht\Vector::shift ( void )

This method shifts a value from the front of a vector (in linear time). Shifting a value from an empty vector will result in an Error exception.

Parameters

This function has no parameters.

Return Values

The value from the front of the vector.

Examples

Example #1 Shifting a value from a vector

<?php

use pht\Vector;

$vector = new Vector();

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

var_dump($vector->shift());

The above example will output:

int(1)

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top