BP_Group_Extension::parse_args_r( array $a, array $b )
Recursive argument parsing.
Description
This acts like a multi-dimensional version of wp_parse_args() (minus the querystring parsing – you must pass arrays).
Values from $a override those from $b; keys in $b that don’t exist in $a are passed through.
This is different from array_merge_recursive(), both because of the order of preference ($a overrides $b) and because of the fact that array_merge_recursive() combines arrays deep in the tree, rather than overwriting the b array with the a array.
The implementation of this function is specific to the needs of BP_Group_Extension, where we know that arrays will always be associative, and that an argument under a given key in one array will be matched by a value of identical depth in the other one. The function is NOT designed for general use, and will probably result in unexpected results when used with data in the wild. See, eg, https://core.trac.wordpress.org/ticket/19888
Parameters
- $a
-
(Required) First set of arguments.
- $b
-
(Required) Second set of arguments.
Return
(array) Parsed arguments.
Source
File: bp-groups/classes/class-bp-group-extension.php
public static function parse_args_r( &$a, $b ) { $a = (array) $a; $b = (array) $b; $r = $b; foreach ( $a as $k => &$v ) { if ( is_array( $v ) && isset( $r[ $k ] ) ) { $r[ $k ] = self::parse_args_r( $v, $r[ $k ] ); } else { $r[ $k ] = $v; } } return $r; }
Changelog
Version | Description |
---|---|
BuddyPress 1.8.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.