reverse

reverse

Reverses the order of the items in an array. reverse cannot reverse a string.

Input

{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}

{{ my_array | reverse | join: ", " }}

Output

plums, peaches, oranges, apples

reverse cannot be used directly on a string, but you can split a string into an array, reverse the array, and rejoin it by chaining together filters:

Input

{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}

Output

.moT rojaM ot lortnoc dnuorG

© 2005, 2006 Tobias Luetke
Licensed under the MIT License.
https://shopify.github.io/liquid/filters/reverse/

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部