將數組中的所有項的順序反轉。reverse
?不能操作字符串。
輸入
{% 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
? Copyright 2023 深圳藍曬科技有限公司. 粵ICP備2023054553號-1