_wp_array_set
- %1$s is private and should not be used in themes or plugins directly.
_wp_array_set ( $input_array, $path, $value = null )
Access:Parameters:- (array) input_array An array that we want to mutate to include a specific value in a path.
- (array) path An array of keys describing the path that we want to mutate.
- (mixed) value The value that will be set.
Defined at: - Introduced in WordPress: 5.8.0
- Deprecated in WordPress: —
Description
Sets an array in depth based on a path of keys.It is the PHP equivalent of JavaScript's `lodash.set()` and mirroring it may help other components
retain some symmetry between client and server implementations.
Example usage:
$input_array = array();
_wp_array_set( $input_array, array( 'a', 'b', 'c', 1 ) );
$input_array becomes:
array(
'a' => array(
'b' => array(
'c' => 1,
),
),
);