如何在PHP中找到关联数组中第一个元素的值?

Eri*_*ric 1 php arrays associative-array

我有这样一个数组:

$array = array(
    'fruit1' => 'apple',
    'fruit2' => 'orange',
    'fruit3' => 'grape',
);
Run Code Online (Sandbox Code Playgroud)

是否有一个函数可以'apple'从该数组中获取(第一个键)?或者我别无选择,只能这样做?

function firstkey($array)
{
    for($array as $first)
    {
        return $first;
    }
}
Run Code Online (Sandbox Code Playgroud)