How to get the value of a current element pointed at by an array internal pointer in PHP

1 Answer

0 votes
$arr = [34, 21, 87, 100, 20, 30];

echo "Current Value is : ". current($arr). "\n";

next($arr);
echo "Current Value is : ". current($arr). "\n";

next($arr);
echo "Current Value is : ". current($arr). "\n";

next($arr);
echo "Current Value is : ";
var_dump(current($arr));




/*
run:

Current Value is : 34
Current Value is : 21
Current Value is : 87
Current Value is : int(100)

*/

 



answered Jun 12, 2023 by avibootz

Related questions

...