You are here

function twig_last in Zircon Profile 8.0

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

Returns the last element of the item.

Parameters

Twig_Environment $env A Twig_Environment instance:

mixed $item A variable:

Return value

mixed The last element of the item

1 call to twig_last()
Twig_Tests_Extension_CoreTest::testTwigLast in vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php
1 string reference to 'twig_last'
Twig_Extension_Core::getFilters in vendor/twig/twig/lib/Twig/Extension/Core.php

File

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

Code

function twig_last(Twig_Environment $env, $item) {
  $elements = twig_slice($env, $item, -1, 1, false);
  return is_string($elements) ? $elements : current($elements);
}