function twig_get_array_keys_filter in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/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/ Extension/ Core.php - Returns a list of filters to add to the existing list.
File
- vendor/
Twig/ Extension/ Core.php, line 864
Code
function twig_get_array_keys_filter($array) {
if (is_object($array) && $array instanceof Traversable) {
return array_keys(iterator_to_array($array));
}
if (!is_array($array)) {
return array();
}
return array_keys($array);
}