WpOrg\Requests\Utility

InputValidator::is_numeric_array_key()public staticWP 1.0

Verify whether a received input parameter is usable as an integer array key.

Method of the class: InputValidator{}

No Hooks.

Return

true|false.

Usage

$result = InputValidator::is_numeric_array_key( $input );
$input(mixed) (required)
Input parameter to verify.

InputValidator::is_numeric_array_key() code WP 6.6.2

public static function is_numeric_array_key($input) {
	if (is_int($input)) {
		return true;
	}

	if (!is_string($input)) {
		return false;
	}

	return (bool) preg_match('`^-?[0-9]+$`', $input);
}