Make WordPress Core

Ticket #33982: 33982-numeric.diff

File 33982-numeric.diff, 739 bytes (added by rmccue, 10 years ago)

Add helper function for detecting numeric-indexed arrays

  • src/wp-includes/functions.php

     
    31773177}
    31783178
    31793179/**
     3180 * Determines if the variable is a numeric-indexed array.
     3181 *
     3182 * @since 4.4.0
     3183 *
     3184 * @param mixed $data Variable to check.
     3185 * @return bool Whether the variable is a list.
     3186 */
     3187function wp_is_numeric_array( $data ) {
     3188        if ( ! is_array( $data ) ) {
     3189                return false;
     3190        }
     3191
     3192        $keys = array_keys( $data );
     3193        $string_keys = array_filter( $keys, 'is_string' );
     3194        return count( $string_keys ) === 0;
     3195}
     3196
     3197/**
    31803198 * Filters a list of objects, based on a set of key => value arguments.
    31813199 *
    31823200 * @since 3.0.0