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.


Top ↑

Return

(bool) Whether the variable is a list.


Top ↑

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


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More