php8.5
Home/ Manual/ ds / stack/ Ds\Stack::push

Ds\Stack::push

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Pushes values onto the stack

Description

Ds\Stack::push(mixed ...$values): void

Pushes values onto the stack.

Parameters

values

The values to push onto the stack.

Return Values

Void

Examples

Ds\Stack::push() example

php
<?php
$stack = new \Ds\Stack();

$stack->push("a");
$stack->push("b");
$stack->push("c", "d");
$stack->push(...["e", "f"]);

print_r($stack);
?>

The above example will output something similar to:

output
Ds\Stack Object
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
    [4] => e
    [5] => f
)

Source: reference/ds/ds/stack/push.xml · from the official PHP manual (php/doc-en)