wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



array_last › WordPress Function

Od6.9.0
Przestarzałyn/a
› array_last ( $array )
Parametry:
  • (array) $array The array to get the last element from.
    Wymagane: Tak
Powrót:
  • (mixed|null) The last element of the array, or null if the array is empty.
Zdefiniowane na:
Codex:

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

Returns the last element of an array.


Źródło

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

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