InputValidator::is_numeric_array_key( mixed $input ): bool

In this article

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

Parameters

$inputmixedrequired
Input parameter to verify.

Return

bool

Source

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);
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.