<?php
$array = array(
4 => 1,
2 => 6
);
/*
Just to be safe
*/
reset($array);
/*
Get first value
*/
echo current($array), PHP_EOL ;
/*
Get key for first value
*/
echo key($array), PHP_EOL ;
It behaves similarly to the other associated functions, here’s a quick overview of what they return.
[INDENT]reset - First value in array end - Last value in array each - Array containing key/value pair (twice) for current item current - Current value key - Current key next - Next value in array prev - Previous value in array[/INDENT]
They will return FALSE if the function cannot get what it wants (e.g. reset() with an empty array, prev() when at the beginning of an array, etc.).