Determines if the variable is a numeric-indexed array.
Description
Note! This answers a different question than array_is_list() and is more flexible to handle situations where some numeric array indices have been removed. A numeric-indexed array is only a “list” when the array keys form a contiguous range from zero to the highest key. Example: true === wp_is_numeric_array( array( 1, 2, 3, 4 ) );
false === wp_is_numeric_array( array( 'name' => 'WordPress' ) );
// All-numeric keys vs. list.
$above_two = array_filter( array( 1, 2, 8, 9 ), fn ( $v ) => $v > 2 );
$above_two === array( '2' => 8, '3' => 9 );
true === wp_is_numeric_array( $above_two );
false === array_is_list( $above_two );
Parameters
$datamixed
Variable to check.
Return
bool
Whether the variable is a list.
Uses · 1
array_all()Polyfill for `array_all()` function added in PHP 8.4.
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.