My solution ---
<%= def banner i, n, span, str = 0, 0, String.new, "listenlightpoetryjournal" until i == str.length do span << "<span id=\"n" << n.to_s << "\" style=\"top: " << (rand(36) - 18).to_s << "px;\">" << str[i] << "</span>" i, n = i + 1, n + 1 end return span end banner %>No more PHP for this one.
Although your solution is fine it can be a little more readable (and re-usable) in rails.
In the controller:
def banner(text)
span = String.new
text.split(//).each_with_index do |c, i|
span += "<span id='#{i}' style='top:#{(rand(36)-18)}px;'>#{c}</span>\n"
end
span
end
Then in the view
<%= banner("listenlightpoetryjournal") %>