CKTIS / PHP
current()
Read the value under the internal array pointer without moving it.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
current(array|object $array): mixedRead the value under the internal array pointer without moving it. A stored false looks just like the false returned at an invalid position. Use key to distinguish the cases; passing an object to this array-pointer function is deprecated since PHP 8.1.
Signature
current(array|object $array): mixed
Example output
[["off",false,"off"],[null,false]]
Examples
<?php
$flags = ["off"=>false,"on"=>true];
$first = [key($flags),current($flags),key($flags)];
next($flags); next($flags);
echo json_encode([$first,[key($flags),current($flags)]]);
Result
[["off",false,"off"],[null,false]]