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



array_key_last › WordPress Function

Since5.9.0
已弃用n/a
array_key_last ( $array )
参数:
  • (array) $array An array.
    Required: Yes
返回:
  • (string|int|null) The last key of array if the array . is not empty; `null` otherwise.
定义在:
文档:

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.


源码

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

		end( $array );

		return key( $array );
	}
}