I\'m trying to obtain the first key of an associative array, without creating a temporary variable via array_keys()
or the like, to pass by reference. Unfortuna
Although array_shift(array_keys($array));
will work, current(array_keys($array));
is faster as it doesn't advance the internal pointer.
Either one will work though.
As @TomcatExodus noted, array_shift();
expects an array passed by reference, so the first example will issue an error. Best to stick with current();