You are here

function twig_cycle in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/lib/Twig/Extension/Core.php \twig_cycle()

Cycles over a value.

Parameters

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

int $position The cycle position:

Return value

string The next value in the cycle

1 string reference to 'twig_cycle'
Twig_Extension_Core::getFunctions in vendor/twig/twig/lib/Twig/Extension/Core.php

File

vendor/twig/twig/lib/Twig/Extension/Core.php, line 347

Code

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