You are here

function _authcache_p13n_array_unique_recursive in Authenticated User Page Caching (Authcache) 7.2

Helper: remove duplicate values from arrays with numeric keys.

Parameters

any &$item: A nested array structure.

any $key: Internal usage.

Related topics

2 calls to _authcache_p13n_array_unique_recursive()
template_preprocess_authcache_p13n_assembly in modules/authcache_p13n/authcache_p13n.module
Preprocess a placeholder for a personalized assembly.
template_preprocess_authcache_p13n_setting in modules/authcache_p13n/authcache_p13n.module
Preprocess a placeholder for a personalized setting.

File

modules/authcache_p13n/authcache_p13n.module, line 515
Provides methods for serving personalized content fragments.

Code

function _authcache_p13n_array_unique_recursive(&$item, $key = NULL) {
  if (!is_array($item)) {
    return is_numeric($key);
  }
  if (count($item)) {
    $has_only_integer_keys = TRUE;
    foreach ($item as $key => &$value) {
      if (!_authcache_p13n_array_unique_recursive($value, $key)) {
        $has_only_integer_keys = FALSE;
      }
    }
    if ($has_only_integer_keys) {
      $item = array_unique($item);
    }
  }
}