获取关联数组中的第一个键

I'm trying to get the first key of an array in an associative array like below. I know I can use key, but I read (on this site), that's it's less efficient.

So I'm using current(array_keys($data)).

Is there another way of doing this? Will I always get the first key when I use current(array_keys($data))? That's what I scared off.

I'm using php 5.3.18. This is the way the script starts off.

<?php
$json = '{"user":"norman","city":"san jose","type":"editor"}';

$data = json_decode($json, true);

echo current(array_keys($data));
//Output I need is "user"
?>

echo current(array_keys($data)); is a long process just use key

 echo key($data);

See Live Demo

Note

$data = json_decode($json, true); would reset the array ... so no need to call reset again

Try with this code:

reset($data);
$first_key = key($data);

Now on PHP 7.3 >=

$firstKey = array_key_first($data);