wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



array_key_last › WordPress Function

Depuis5.9.0
Dépréciéen/a
array_key_last ( $array )
Paramètres:
  • (array) $array An array.
    Requis: Oui
Retourne:
  • (string|int|null) The last key of array if the array . is not empty; `null` otherwise.
Défini(e) dans:
Codex:

Polyfill for `array_key_last()` function added in PHP 7.3.

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


Source

function array_key_last( array $array ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound
		if ( empty( $array ) ) {
			return null;
		}

		end( $array );

		return key( $array );
	}
}