You are here

function _ad_flatten in Advertisement 7.3

Flatten a structure into an array suitable to be the base of a cache id.

Parameters

$parts: A structure to flatten.

Return value

array An array which can be imploded to get a cache id.

1 call to _ad_flatten()
ad_get_cache in ./ad.module
Return the eventually cached results of a callback

File

./ad.module, line 469
Core code for the ad module.

Code

function _ad_flatten($parts) {
  $result = array();
  if (is_array($parts)) {
    foreach ($parts as $key => $value) {
      $result[] = $key;
      $result = array_merge($result, _ad_flatten($value));
    }
  }
  elseif (is_object($parts)) {
    $result = array_merge($result, _ad_flatten(ad_object_to_array($parts)));
  }
  else {
    $result = array(
      $parts,
    );
  }
  return $result;
}