function twig_get_array_keys_filter in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/twig/twig/lib/Twig/Extension/Core.php \twig_get_array_keys_filter()
Returns the keys for the given array.
It is useful when you want to iterate over the keys of an array:
<pre> {% for key in array|keys %} {# ... #} {% endfor %} </pre>
Parameters
array $array An array:
Return value
array The keys
1 string reference to 'twig_get_array_keys_filter'
- Twig_Extension_Core::getFilters in vendor/
twig/ twig/ lib/ Twig/ Extension/ Core.php
File
- vendor/
twig/ twig/ lib/ Twig/ Extension/ Core.php, line 884
Code
function twig_get_array_keys_filter($array) {
if ($array instanceof Traversable) {
return array_keys(iterator_to_array($array));
}
if (!is_array($array)) {
return array();
}
return array_keys($array);
}