WordPress.org

Make WordPress Core

#47725 closed enhancement (duplicate)

wp_parse_args_deep

Reported by: tazotodua Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.3
Component: General Keywords:
Focuses: Cc:

Description

It would be nice if WP had built-in wp_parse_args for recursive usage (multi-dimensional arrays).

The concept is written here: https://mekshq.com/recursive-wp-parse-args-wordpress-function/

I am new to submitting patches, so my applied patch might need correction. thanks.

Attachments (1)

wp_parse_args_deep.diff (1.1 KB) - added by tazotodua 13 months ago.

Download all attachments as: .zip

Change History (2)

#1 @pento
13 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thank you for the suggestion and patch, @tazotodua!

This is an interesting idea, but as described in #19888, I don't think it's a good option for core.

For the example you describe in your post, you could just use array_merge_recursive(), instead. wp_parse_args() is mostly just a helper function that runs wp_parse_str() first (in case the args are passed as a string), then runs an array_merge().

Note: See TracTickets for help on using tickets.