reverse

v1.9.1

反转数组的所有元素,不可用于字符串。

输入

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

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

输出



plums, peaches, oranges, apples

尽管 reverse 不能直接用于字符串,可以把字符串分割成数组,反转后再连接成字符串:

输入

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

输出

.moT rojaM ot lortnoc dnuorG