我需要拆分字符串并从底部开始在我的视图中打印它。标准方式从头开始读取字符串并进行相应打印。我如何扭转它?Ruby-rails - 拆分字符串并按相反顺序打印
<% @a[:log].to_s.split(/----/).each do |line| %>
<div width='100%'><pre class="log"><%= "#{line}" %></pre></div>
<% end %>
@a[:log] is a string something like this: One ---- Two ---- Three ---- Four
I want this printed reverse starting from Four, instead of One.
<div width='100%'><pre class="log">Four</pre></div>
<div width='100%'><pre class="log">Three</pre></div>
<div width='100%'><pre class="log">Two</pre></div>
<div width='100%'><pre class="log">One</pre></div>
哇。不知道那很容易。谢谢! – 2012-04-14 14:12:52
不客气! – Mischa 2012-04-14 14:24:44