wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



array_key_first › WordPress Function

Desde5.9.0
Obsoleton/a
array_key_first ( $array )
Parâmetros:
  • (array) $array An array.
    Required: Yes
Retorna:
  • (string|int|null) The first key of array if the array is not empty; `null` otherwise.
Definido em:
Codex:

Polyfill for array_key_first() function added in PHP 7.3.

Get the first key of the given array without affecting the internal array pointer.


Fonte

function array_key_first( array $array ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound
		foreach ( $array as $key => $value ) {
			return $key;
		}
	}
}