wpseek.com
WordPress开发者和主题制作者的搜索引擎



array_last › WordPress Function

Since6.9.0
已弃用n/a
› array_last ( $array )
参数:
  • (array) $array The array to get the last element from.
    Required: Yes
返回:
  • (mixed|null) The last element of the array, or null if the array is empty.
定义在:
文档:

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

Returns the last element of an array.


源码

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

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