public static function VarUtils::getCombinations

2 calls to VarUtils::getCombinations()
AssetWriter::getCombinations in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/AssetWriter.php
Not used.
AssetWriter::writeAsset in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/AssetWriter.php

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Util/VarUtils.php, line 50

Class

VarUtils
Variable utilities.

Namespace

Assetic\Util

Code

public static function getCombinations(array $vars, array $values) {
  if (!$vars) {
    return array(
      array(),
    );
  }
  $combinations = array();
  $nbValues = array();
  foreach ($values as $var => $vals) {
    if (!in_array($var, $vars, true)) {
      continue;
    }
    $nbValues[$var] = count($vals);
  }
  for ($i = array_product($nbValues), $c = $i * 2; $i < $c; $i++) {
    $k = $i;
    $combination = array();
    foreach ($vars as $var) {
      $combination[$var] = $values[$var][$k % $nbValues[$var]];
      $k = intval($k / $nbValues[$var]);
    }
    $combinations[] = $combination;
  }
  return $combinations;
}