function twig_test_iterable

Checks if a variable is traversable.

<pre> {# evaluates to true if the foo variable is an array or a traversable object #} {% if foo is traversable %} {# ... #} {% endif %} </pre>

Parameters

mixed $value A variable:

Return value

Boolean true if the value is traversable

1 string reference to 'twig_test_iterable'
Twig_Extension_Core::getTests in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of tests to add to the existing list.

File

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

Code

function twig_test_iterable($value) {
  return $value instanceof Traversable || is_array($value);
}