PHP to Ruby
Convert PHP code into Ruby!
-
nl2br
Posted on July 4th, 2009 2 commentsThe nl2br() function inserts HTML <br> tags before any new lines in a string.
PHP
echo nl2br("foo has a\n bar"); /* foo has a<br> bar */
Ruby
p "foo has a\n bar".gsub("\n", "<br>\n") # foo has a<br> # bar


