What is the Ruby equivalent of the PHP statement
<?php echo substr("abcdefghijklm", 0, 5); ?>
Use the bracket notation, with the same two arguments as for
substring = bigstring[0,5]
I used to recommend http://railsforphp.com/substr as a great way to find Ruby/Rails equivalents for common PHP functions, but apparently it’s no longer online. That’s unfortunate :/
"abcdefghijklm".byteslice(0, 5) => "abcde"