SplFixedArray::current

(PHP 5 >= 5.3.0, PHP 7)

SplFixedArray::current現在の配列の要素を返す

説明

public SplFixedArray::current(): mixed

現在の配列の要素を取得します。

パラメータ

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

戻り値

現在の要素の値を返します。

エラー / 例外

内部の配列ポインタが無効なインデックスを指していたり、範囲外にあったりする場合に RuntimeException をスローします。

add a note

User Contributed Notes 1 note

up
0
kishor10d at gmail dot com
4 years ago
<?php

/**
* current() : It returns current element in the SplFixedArray.
*/

$arr = new SplFixedArray(5);

$arr[1] = 2;
$arr[2] = "foo";

var_dump($arr->current());
echo
"<br>";

$arr->next();
var_dump($arr->current());
echo
"<br>";

$arr->next();
var_dump($arr->current());
echo
"<br>";

?>

The output of this will be:

NULL
int(2)
string(3) "foo"
To Top