wp_is_numeric_array() WordPress Function
The wp_is_numeric_array() function is used to check whether an array is made up of only numeric values. This can be useful when checking user input, for example.
wp_is_numeric_array( mixed $data ) #
Determines if the variable is a numeric-indexed array.
Parameters
- $data
(mixed)(Required)Variable to check.
Return
(bool) Whether the variable is a list.
Source
File: wp-includes/functions.php
function wp_is_numeric_array( $data ) {
if ( ! is_array( $data ) ) {
return false;
}
$keys = array_keys( $data );
$string_keys = array_filter( $keys, 'is_string' );
return count( $string_keys ) === 0;
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |