« Ds\Stack::push
Ds\Queue »

Ds\Stack::toArray

(PECL ds >= 1.0.0)

Ds\Stack::toArray — Converts the stack to an array

説明

public function Ds\Stack::toArray(): array

Converts the stack to an array.

注意:

Casting to an array is not supported yet.

パラメータ

この関数にはパラメータはありません。

戻り値

An array containing all the values in the same order as the stack.

例

例1 Ds\Stack::toArray() example

<?php
$stack = new \Ds\Stack([1, 2, 3]);

var_dump($stack->toArray());
?>

上の例の出力は、 たとえば以下のようになります。

array(3) {
  [0]=>
  int(3)
  [1]=>
  int(2)
  [2]=>
  int(1)
}
関連キーワード:
stack   Stack   toArray   Converts   push   Queue   Casting   supported   containing   values   order   example   dump
関連する関数・ページ:
ds-stack.pop   ds-stack.peek   class.ds-stack   ds-stack.clear   ds-stack.count   ds-stack.push