wpseek.com
A WordPress-centric search engine for devs and theme authors



array_key_last › WordPress Function

Since5.9.0
Deprecatedn/a
array_key_last ( $arr )
Parameters:
  • (array) $arr An array.
    Required: Yes
Returns:
  • (string|int|null) The last key of array if the array . is not empty; `null` otherwise.
Defined at:
Codex:

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.


Source

function array_key_last( array $arr ) {
		if ( empty( $arr ) ) {
			return null;
		}
		end( $arr );
		return key( $arr );
	}
}