You are here

function _mailchimp_campaign_recursive_unset in Mailchimp 7.4

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_campaign/mailchimp_campaign.module \_mailchimp_campaign_recursive_unset()
  2. 7.3 modules/mailchimp_campaign/mailchimp_campaign.module \_mailchimp_campaign_recursive_unset()

Helper function to recursively unset a given key from an array.

Used here by mailchimp_campaign_process_callback() to remove all contextual links, even from nested entity objects.

Parameters

array $array Array that needs keys removed.:

string $unwanted_key Key that needs to be removed.:

1 call to _mailchimp_campaign_recursive_unset()
mailchimp_campaign_process_callback in modules/mailchimp_campaign/mailchimp_campaign.module
Callback for preg_replace in mailchimp_campaign_filter_campaign_process().

File

modules/mailchimp_campaign/mailchimp_campaign.module, line 738
Module file for mailchimp_campaign.

Code

function _mailchimp_campaign_recursive_unset(&$array, $unwanted_key) {

  // Remove key from top level of array.
  if (isset($array[$unwanted_key])) {
    unset($array[$unwanted_key]);
  }

  // Recurse through any remaining keys that may themselves be arrays.
  foreach ($array as &$value) {
    if (is_array($value)) {
      _mailchimp_campaign_recursive_unset($value, $unwanted_key);
    }
  }
}