wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



array_last › WordPress Function

Seit6.9.0
Veraltetn/v
array_last ( $array )
Parameter:
  • (array) $array The array to get the last element from.
    Erforderlich: Ja
Gibt zurück:
  • (mixed|null) The last element of the array, or null if the array is empty.
Definiert in:
Codex:

Polyfill for `array_last()` function added in PHP 8.5.

Returns the last element of an array.


Quellcode

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

		return $array[ array_key_last( $array ) ];
	}
}