Tutorials References Exercises Videos Menu
Free Website Get Certified Upgrade

Template Filter - last


Example

Return the last item in a list:

<h1>{{ fruits|last }}</h1>
Run Example »

Definition and Usage

The last filter returns the last item of an object.

For strings, the last filter returns the last character:

Example

Return the last character of a string:

<h1>{{ firstname|last }}</h1>
Run Example »

Use the first filter to return the first item.


Syntax

Template filters are defined by using a pipe | character followed by the name of the filter.

{{ value|last }}