Title: _wp_array_get
Published: December 9, 2020
Last modified: February 24, 2026

---

# _wp_array_get( array $input_array, array $path, mixed $default_value = null ): mixed

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Accesses an array in depth based on a path of keys.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#description)󠁿

It is the PHP equivalent of JavaScript’s `lodash.get()` and mirroring it may help
other components retain some symmetry between client and server implementations.

Example usage:

    ```php
    $input_array = array(
        'a' => array(
            'b' => array(
                'c' => 1,
            ),
        ),
    );
    _wp_array_get( $input_array, array( 'a', 'b', 'c' ) );
    ```

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#parameters)󠁿

 `$input_array`arrayrequired

An array from which we want to retrieve some information.

`$path`arrayrequired

An array of keys describing the path with which to retrieve information.

`$default_value`mixedoptional

The return value if the path does not exist within the array, or if `$input_array`
or `$path` are not arrays.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#return)󠁿

 mixed The value from the path specified.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#source)󠁿

    ```php
    function _wp_array_get( $input_array, $path, $default_value = null ) {
    	// Confirm $path is valid.
    	if ( ! is_array( $path ) || 0 === count( $path ) ) {
    		return $default_value;
    	}

    	foreach ( $path as $path_element ) {
    		if ( ! is_array( $input_array ) ) {
    			return $default_value;
    		}

    		if ( is_string( $path_element )
    			|| is_integer( $path_element )
    			|| null === $path_element
    		) {
    			/*
    			 * Check if the path element exists in the input array.
    			 * We check with `isset()` first, as it is a lot faster
    			 * than `array_key_exists()`.
    			 */
    			if ( isset( $path_element, $input_array[ $path_element ] ) ) {
    				$input_array = $input_array[ $path_element ];
    				continue;
    			}

    			/*
    			 * If `isset()` returns false, we check with `array_key_exists()`,
    			 * which also checks for `null` values.
    			 */
    			if ( isset( $path_element ) && array_key_exists( $path_element, $input_array ) ) {
    				$input_array = $input_array[ $path_element ];
    				continue;
    			}
    		}

    		return $default_value;
    	}

    	return $input_array;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L5084)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L5084-L5123)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#related)󠁿

| Used by | Description | 
| [_block_bindings_pattern_overrides_get_value()](https://developer.wordpress.org/reference/functions/_block_bindings_pattern_overrides_get_value/)`wp-includes/block-bindings/pattern-overrides.php` |

Gets value for the Pattern Overrides source.

  | 
| [wp_get_block_css_selector()](https://developer.wordpress.org/reference/functions/wp_get_block_css_selector/)`wp-includes/global-styles-and-settings.php` |

Determines the CSS selector for the block type and property provided, returning it if available.

  | 
| [WP_Duotone::get_all_global_style_block_names()](https://developer.wordpress.org/reference/classes/wp_duotone/get_all_global_style_block_names/)`wp-includes/class-wp-duotone.php` |

Scrape all block names from global styles and store in self::$global_styles_block_names.

  | 
| [WP_Theme_JSON::remove_indirect_properties()](https://developer.wordpress.org/reference/classes/wp_theme_json/remove_indirect_properties/)`wp-includes/class-wp-theme-json.php` |

Removes indirect properties from the given input node and sets in the given output node.

  | 
| [wp_typography_get_css_variable_inline_style()](https://developer.wordpress.org/reference/functions/wp_typography_get_css_variable_inline_style/)`wp-includes/deprecated.php` |

Generates an inline style for a typography feature e.g. text decoration, text transform, and font style.

  | 
| [WP_Theme_JSON::get_styles_for_block()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_styles_for_block/)`wp-includes/class-wp-theme-json.php` |

Gets the CSS rules for a particular block from theme.json.

  | 
| [WP_Theme_JSON::get_layout_styles()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_layout_styles/)`wp-includes/class-wp-theme-json.php` |

Gets the CSS layout rules for a particular block from theme.json layout definitions.

  | 
| [WP_Style_Engine::parse_block_styles()](https://developer.wordpress.org/reference/classes/wp_style_engine/parse_block_styles/)`wp-includes/style-engine/class-wp-style-engine.php` |

Returns classnames and CSS based on the values in a styles object.

  | 
| [WP_Style_Engine::get_individual_property_css_declarations()](https://developer.wordpress.org/reference/classes/wp_style_engine/get_individual_property_css_declarations/)`wp-includes/style-engine/class-wp-style-engine.php` |

Style value parser that returns a CSS definition array comprising style properties that have keys representing individual style properties, otherwise known as longhand CSS properties.

  | 
| [WP_Theme_JSON::get_data()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_data/)`wp-includes/class-wp-theme-json.php` |

Returns a valid theme.json as provided by a theme.

  | 
| [WP_Theme_JSON::get_metadata_boolean()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_metadata_boolean/)`wp-includes/class-wp-theme-json.php` |

For metadata values that can either be booleans or paths to booleans, gets the value.

  | 
| [WP_Theme_JSON::get_svg_filters()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_svg_filters/)`wp-includes/class-wp-theme-json.php` |

Converts all filter (duotone) presets into SVGs.

  | 
| [wp_get_global_settings()](https://developer.wordpress.org/reference/functions/wp_get_global_settings/)`wp-includes/global-styles-and-settings.php` |

Gets the settings resulting of merging core, theme, and user data.

  | 
| [wp_get_global_styles()](https://developer.wordpress.org/reference/functions/wp_get_global_styles/)`wp-includes/global-styles-and-settings.php` |

Gets the styles resulting of merging core, theme, and user data.

  | 
| [WP_Theme_JSON_Schema::rename_settings()](https://developer.wordpress.org/reference/classes/wp_theme_json_schema/rename_settings/)`wp-includes/class-wp-theme-json-schema.php` |

Processes a settings array, renaming or moving properties.

  | 
| [WP_Theme_JSON::should_override_preset()](https://developer.wordpress.org/reference/classes/wp_theme_json/should_override_preset/)`wp-includes/class-wp-theme-json.php` |

Determines whether a presets should be overridden or not.

  | 
| [WP_Theme_JSON::get_default_slugs()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_default_slugs/)`wp-includes/class-wp-theme-json.php` |

Returns the default slugs for all the presets in an associative array whose keys are the preset paths and the leaves is the list of slugs.

  | 
| [WP_Theme_JSON::get_name_from_defaults()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_name_from_defaults/)`wp-includes/class-wp-theme-json.php` |

Gets a `default`‘s preset name by a provided slug.

  | 
| [WP_Theme_JSON::remove_insecure_properties()](https://developer.wordpress.org/reference/classes/wp_theme_json/remove_insecure_properties/)`wp-includes/class-wp-theme-json.php` |

Removes insecure data from theme.json.

  | 
| [WP_Theme_JSON::remove_insecure_settings()](https://developer.wordpress.org/reference/classes/wp_theme_json/remove_insecure_settings/)`wp-includes/class-wp-theme-json.php` |

Processes a setting node and returns the same node without the insecure settings.

  | 
| [WP_Theme_JSON::remove_insecure_styles()](https://developer.wordpress.org/reference/classes/wp_theme_json/remove_insecure_styles/)`wp-includes/class-wp-theme-json.php` |

Processes a style node and returns the same node without the insecure styles.

  | 
| [WP_Theme_JSON::get_preset_classes()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_preset_classes/)`wp-includes/class-wp-theme-json.php` |

Creates new rulesets as classes for each preset value such as:

  | 
| [WP_Theme_JSON::get_settings_values_by_slug()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_settings_values_by_slug/)`wp-includes/class-wp-theme-json.php` |

Gets preset values keyed by slugs based on settings and metadata.

  | 
| [WP_Theme_JSON::get_settings_slugs()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_settings_slugs/)`wp-includes/class-wp-theme-json.php` |

Similar to get_settings_values_by_slug, but doesn’t compute the value.

  | 
| [WP_Theme_JSON::do_opt_in_into_settings()](https://developer.wordpress.org/reference/classes/wp_theme_json/do_opt_in_into_settings/)`wp-includes/class-wp-theme-json.php` |

Enables some settings.

  | 
| [WP_Theme_JSON::compute_style_properties()](https://developer.wordpress.org/reference/classes/wp_theme_json/compute_style_properties/)`wp-includes/class-wp-theme-json.php` |

Given a styles array, it extracts the style properties and adds them to the $declarations array following the format:

  | 
| [WP_Theme_JSON::get_property_value()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_property_value/)`wp-includes/class-wp-theme-json.php` |

Returns the style property for the given path.

  | 
| [WP_Theme_JSON::merge()](https://developer.wordpress.org/reference/classes/wp_theme_json/merge/)`wp-includes/class-wp-theme-json.php` |

Merges new incoming data.

  | 
| [WP_Theme_JSON::__construct()](https://developer.wordpress.org/reference/classes/wp_theme_json/__construct/)`wp-includes/class-wp-theme-json.php` |

Constructor.

  | 
| [WP_Theme_JSON::get_stylesheet()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_stylesheet/)`wp-includes/class-wp-theme-json.php` |

Returns the stylesheet that results of processing the theme.json structure this object represents.

  | 
| [WP_Theme_JSON::get_css_variables()](https://developer.wordpress.org/reference/classes/wp_theme_json/get_css_variables/)`wp-includes/class-wp-theme-json.php` |

Converts each styles section into a list of rulesets to be appended to the stylesheet.

  | 
| [block_has_support()](https://developer.wordpress.org/reference/functions/block_has_support/)`wp-includes/blocks.php` |

Checks whether the current block type supports the feature requested.

  |

[Show 27 more](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_array_get/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.6.0](https://developer.wordpress.org/reference/since/5.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_array_get%2F)
before being able to contribute a note or feedback.