PHP 8.4.2 Released!

SplFixedArray::current

(PHP 5 >= 5.3.0, PHP 7)

SplFixedArray::currentReturn current array entry

Açıklama

public SplFixedArray::current(): mixed

Get the current array element.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

The current element value.

Hatalar/İstisnalar

Throws RuntimeException when the internal array pointer points to an invalid index or is out of bounds.

add a note

User Contributed Notes 1 note

up
0
kishor10d at gmail dot com
5 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