array_combine example



            if (\is_string($v)) {
                $values[$k] = new static($v);
            } elseif (\is_array($v) && $values[$k] !== $v = static::wrap($v)) {
                $values[$k] = $v;
            }

            ++$i;
        }

        return null !== $keys ? array_combine($keys$values) : $values;
    }

    /** * @param string|string[] $needle */
    public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0)static
    {
        $str = clone $this;
        $i = \PHP_INT_MAX;

        if (\is_string($needle)) {
            

  protected function getViewsDisplayIDsWithRoute() {
    if (!isset($this->viewsDisplayPairs)) {
      $this->viewsDisplayPairs = [];

      // @todo Convert this method to some service.       $views = $this->getApplicableViews();
      foreach ($views as $data) {
        [$view_id$display_id] = $data;
        $this->viewsDisplayPairs[] = $view_id . '.' . $display_id;
      }
      $this->viewsDisplayPairs = array_combine($this->viewsDisplayPairs, $this->viewsDisplayPairs);
    }
    return $this->viewsDisplayPairs;
  }

  /** * Returns a set of route objects. * * @return \Symfony\Component\Routing\RouteCollection * A route collection. */
  public function routes() {
    
// Get all enabled languages.     $translated_languages = $this->enabledLanguages;

    // Load all the content from any CSV files that exist for enabled languages.     foreach ($translated_languages as $language) {
      if (file_exists($default_content_path . "$language/$filename") &&
      ($handle = fopen($default_content_path . "$language/$filename", 'r')) !== FALSE) {
        $header = fgetcsv($handle);
        $line_counter = 0;
        while (($content = fgetcsv($handle)) !== FALSE) {
          $keyed_content[$language][$line_counter] = array_combine($header$content);
          $line_counter++;
        }
        fclose($handle);
      }
      else {
        // Language directory exists, but the file in this language was not found,         // remove that language from list of languages to be translated.         $key = array_search($language$translated_languages);
        unset($translated_languages[$key]);
      }
    }
    
$optimized_tokens = $this->optimizeTokens($context_tokens);
    // Iterate over cache contexts that have been optimized away and get their     // cacheability metadata.     foreach (static::parseTokens(array_diff($context_tokens$optimized_tokens)) as $context_token) {
      [$context_id$parameter] = $context_token;
      $context = $this->getService($context_id);
      $cacheable_metadata = $cacheable_metadata->merge($context->getCacheableMetadata($parameter));
    }

    sort($optimized_tokens);
    $keys = [];
    foreach (array_combine($optimized_tokensstatic::parseTokens($optimized_tokens)) as $context_token => $context) {
      [$context_id$parameter] = $context;
      $keys[] = '[' . $context_token . ']=' . $this->getService($context_id)->getContext($parameter);
    }

    // Create the returned object and merge in the cacheability metadata.     $context_cache_keys = new ContextCacheKeys($keys);
    return $context_cache_keys->merge($cacheable_metadata);
  }

  /** * Optimizes cache context tokens (the minimal representative subset). * * A minimal representative subset means that any cache context token in the * given set of cache context tokens that is a property of another cache * context cache context token in the set, is removed. * * Hence a minimal representative subset is the most compact representation * possible of a set of cache context tokens, that still captures the entire * universe of variations. * * If a cache context is being optimized away, it is able to set cacheable * metadata for itself which will be bubbled up. * * For example, when caching per user ('user'), also caching per role * ('user.roles') is meaningless because "per role" is implied by "per user". * * In the following examples, remember that the period indicates hierarchy and * the colon can be used to get a specific value of a calculated cache * context: * - ['a', 'a.b'] -> ['a'] * - ['a', 'a.b.c'] -> ['a'] * - ['a.b', 'a.b.c'] -> ['a.b'] * - ['a', 'a.b', 'a.b.c'] -> ['a'] * - ['x', 'x:foo'] -> ['x'] * - ['a', 'a.b.c:bar'] -> ['a'] * * @param string[] $context_tokens * A set of cache context tokens. * * @return string[] * A representative subset of the given set of cache context tokens.. */

  public static function years($min = 0, $max = 0, $required = FALSE) {
    // Ensure $min and $max are valid values.     if (empty($min)) {
      $min = intval(date('Y', REQUEST_TIME) - 3);
    }
    if (empty($max)) {
      $max = intval(date('Y', REQUEST_TIME) + 3);
    }
    $none = ['' => ''];
    $range = range($min$max);
    $range = array_combine($range$range);
    return !$required ? $none + $range : $range;
  }

  /** * Constructs an array of days in a month. * * @param bool $required * (optional) If FALSE, the returned array will include a blank value. * Defaults to FALSE. * @param int $month * (optional) The month in which to find the number of days. Defaults to * NULL. * @param int $year * (optional) The year in which to find the number of days. Defaults to * NULL. * * @return array * An array of days for the selected month. */
$elements = [
      '_info_file_ctime',
      'datestamp',
      'major',
      'name',
      'package',
      'project',
      'project status url',
      'version',
    ];
    $elements = array_merge($elements$additional_elements);
    return array_intersect_key($infoarray_combine($elements$elements));
  }

}
/** * Constructs a TestLazyPluginCollection object. * * @param \Drupal\Component\Plugin\PluginManagerInterface $manager * The plugin manager that handles test plugins. */
  public function __construct(PluginManagerInterface $manager) {
    $this->manager = $manager;

    $instance_ids = array_keys($this->manager->getDefinitions());
    $this->instanceIds = array_combine($instance_ids$instance_ids);
  }

  /** * {@inheritdoc} */
  protected function initializePlugin($instance_id) {
    $this->pluginInstances[$instance_id] = $this->manager->createInstance($instance_id[]);
  }

  /** * {@inheritdoc} */
// Test without menu name.     $this->assertSame($expected_link$this->menuActiveTrail->getActiveLink());
  }

  /** * Tests getActiveTrailIds(). * * @covers ::getActiveTrailIds * @dataProvider provider */
  public function testGetActiveTrailIds(Request $request$links$menu_name$expected_link$expected_trail) {
    $expected_trail_ids = array_combine($expected_trail$expected_trail);

    $this->requestStack->push($request);
    if ($links !== FALSE) {
      // We expect exactly two calls, one for the first call, and one after the       // cache clearing below.       $this->menuLinkManager->expects($this->exactly(2))
        ->method('loadLinksbyRoute')
        ->with('baby_llama')
        ->willReturn($links);
      if ($expected_link !== NULL) {
        $this->menuLinkManager->expects($this->exactly(2))
          
if (\count($customFieldAllowList) === 0) {
            $lineItem->setPayloadValue('customFields', []);

            return;
        }

        $lineItem->setPayloadValue(
            'customFields',
            array_intersect_key(
                $customFields,
                array_combine(
                    $customFieldAllowList,
                    $customFieldAllowList
                )
            )
        );
    }
}

  protected function replaceName($name$data) {
    if (preg_match_all("/\[(.*)\]/U", $name$matches)) {
      // Build our list of '[value]' => replacement.       $replace = [];
      foreach (array_combine($matches[0]$matches[1]) as $key => $value) {
        $replace[$key] = $this->replaceVariable($value$data);
      }
      return strtr($name$replace);
    }
    else {
      return $name;
    }
  }

  /** * Replaces variable values in included names with configuration data. * * Variable values are nested configuration keys that will be replaced by * their value or some of these special strings: * - '%key', will be replaced by the element's key. * - '%parent', to reference the parent element. * - '%type', to reference the schema definition type. Can only be used in * combination with %parent. * * There may be nested configuration keys separated by dots or more complex * patterns like '%parent.name' which references the 'name' value of the * parent element. * * Example patterns: * - 'name.subkey', indicates a nested value of the current element. * - '%parent.name', will be replaced by the 'name' value of the parent. * - '%parent.%key', will be replaced by the parent element's key. * - '%parent.%type', will be replaced by the schema type of the parent. * - '%parent.%parent.%type', will be replaced by the schema type of the * parent's parent. * * @param string $value * Variable value to be replaced. * @param mixed $data * Configuration data for the element. * * @return string * The replaced value if a replacement found or the original value if not. */

        if (\count($values) < \count($params)) {
            $params = \array_slice($params, 0, \count($values));
        } elseif (\count($values) > \count($params)) {
            $values[] = new EnumStub(array_splice($values, \count($params)), false);
            $params[] = $variadic;
        }
        if (['...'] === $params) {
            $this->dumpKeys = false;
            $this->value = $values[0]->value;
        } else {
            $this->value = array_combine($params$values);
        }
    }

    private static function getParameters(string $function, ?string $class): array
    {
        if (isset(self::$parameters[$k = $class.'::'.$function])) {
            return self::$parameters[$k];
        }

        try {
            $r = null !== $class ? new \ReflectionMethod($class$function) : new \ReflectionFunction($function);
        }
$ids->getIdArray(['tag-1', 'tag-2']),
        ];
    }

    /** * @param array<string> $ids * * @return array<string, mixed> */
    private static function keys(array $ids): array
    {
        $return = \array_combine($ids, \array_fill(0, \count($ids), true));

        static::assertIsArray($return);

        return $return;
    }
}
/** * Fetches a new blank row (not from the database). * * @param array $data OPTIONAL data to populate in the new row. * @param string $defaultSource OPTIONAL flag to force default values into new row * @return Zend_Db_Table_Row_Abstract */
    public function createRow(array $data = array()$defaultSource = null)
    {
        $cols     = $this->_getCols();
        $defaults = array_combine($colsarray_fill(0, count($cols), null));

        // nothing provided at call-time, take the class value         if ($defaultSource == null) {
            $defaultSource = $this->_defaultSource;
        }

        if (!in_array($defaultSource, array(self::DEFAULT_CLASS, self::DEFAULT_DB, self::DEFAULT_NONE))) {
            $defaultSource = self::DEFAULT_NONE;
        }

        if ($defaultSource == self::DEFAULT_DB) {
            
$ids->getIdArray(['tag-1', 'tag-2']),
        ];
    }

    /** * @param array<string> $ids * * @return array<string, mixed> */
    private static function keys(array $ids): array
    {
        $return = \array_combine($ids, \array_fill(0, \count($ids), true));

        static::assertIsArray($return);

        return $return;
    }
}
$options['hide_alter_empty'] = ['default' => TRUE];

    return $options;
  }

  /** * Performs some cleanup tasks on the options array before saving it. */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    $options = &$form_state->getValue('options');
    $types = ['element_type', 'element_label_type', 'element_wrapper_type'];
    $classes = array_combine(['element_class', 'element_label_class', 'element_wrapper_class']$types);

    foreach ($types as $type) {
      if (!$options[$type . '_enable']) {
        $options[$type] = '';
      }
    }

    foreach ($classes as $class => $type) {
      if (!$options[$class . '_enable'] || !$options[$type . '_enable']) {
        $options[$class] = '';
      }
    }
Home | Imprint | This part of the site doesn't use cookies.