mixed SplFixedArray::current()Parameters:this the function takes no parameters.Return value:this function returns the current record of the array.The programs below illustrate the function SplFixedArray::current()in PHP:Program 1:
// Create some fixed size array
$gfg
=
new
SplFixedArray ( 6);
$gfg
[0] = 1;
$gfg
[1] = 5;
$gfg
[2] = 1;
$gfg
[3] = 11;
$gfg
[4] = 15;
$gfg
[5] = 17;
$gfg
-> next();
echo
$gfg
-> current().
""
;
$gfg
->
rewind
();
echo
$gfg
-> current().
""
;
?>
Exit:5 1
Program 2:
// Create some fixed size array
$gfg
=
new
SplFixedArray (6);
$gfg
[0] = 1;
$gfg
[1] = 5;
$gfg
[2] = 1;
$gfg
[3] = 11;
$gfg
[4] = 15;
$gfg
[5] = 17;
// Loop through the array and display its values
while
(
$gfg
-> valid()) {
echo
$gfg
-> current().
""
;
$gfg
-> next();
}
?>
Exit:1 5 1 11 15 17
Link: https://www.php .net / manual / en / splfixedarray.current.php
Shop
Latest questions
Wiki