Verify whether a received input parameter is usable as an integer array key.
Parameters
$input
mixedrequired- Input parameter to verify.
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.