You are here

protected static function i18n_string_textgroup_default::multiple_combine in Internationalization 7

Build combinations of an array of arrays respecting keys.

Example: array(array(a,b), array(1,2)) will translate into array(a,1), array(a,2), array(b,1), array(b,2)

1 call to i18n_string_textgroup_default::multiple_combine()
i18n_string_textgroup_default::multiple_translation_search in i18n_string/i18n_string.inc
Search multiple translations with key combinations.

File

i18n_string/i18n_string.inc, line 819
API for internationalization strings

Class

i18n_string_textgroup_default
Textgroup handler for i18n_string API

Code

protected static function multiple_combine($properties) {
  $combinations = array();

  // Get first key, value. We need to make sure the array pointer is reset.
  $value = reset($properties);
  $key = key($properties);
  array_shift($properties);
  $values = is_array($value) ? $value : array(
    $value,
  );
  foreach ($values as $value) {
    if ($properties) {
      foreach (self::multiple_combine($properties) as $merge) {
        $combinations[] = array_merge(array(
          $key => $value,
        ), $merge);
      }
    }
    else {
      $combinations[] = array(
        $key => $value,
      );
    }
  }
  return $combinations;
}