array_last( array $array )
Polyfill for array_last() function added in PHP 8.5.
Description
Returns the last element of an array.
Parameters
- $array
-
(Required) The array to get the last element from.
Return
(mixed|null) The last element of the array, or null if the array is empty.
Source
File: wp-includes/compat.php
function array_last( array $array ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound
if ( empty( $array ) ) {
return null;
}
return $array[ array_key_last( $array ) ];
}
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Introduced. |