function twig_cycle

Cycles over a value.

Parameters

ArrayAccess|array $values An array or an ArrayAccess instance:

integer $i The cycle value:

Return value

string The next value in the cycle

1 string reference to 'twig_cycle'
Twig_Extension_Core::getFunctions in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of global functions to add to the existing list.

File

drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php, line 301

Code

function twig_cycle($values, $i) {
  if (!is_array($values) && !$values instanceof ArrayAccess) {
    return $values;
  }
  return $values[$i % count($values)];
}