Ruby alternative to php's implode and expload functions

is there a method similar to php’s expload function in ruby. i have a
database field that contains an array of items, when i output this field
i notice the items are seperated by ‘-’ e.g item1-item2-item3.

how would i go about putting them back into an array in ruby. for
example in PHP i would just do this:

$field; // = item1-item2-item3
$field_as_array = explode(’-’,$field);

mmaki wrote:

is there a method similar to php’s expload function in ruby. i have a
database field that contains an array of items, when i output this field
i notice the items are seperated by ‘-’ e.g item1-item2-item3.

how would i go about putting them back into an array in ruby. for
example in PHP i would just do this:

$field; // = item1-item2-item3
$field_as_array = explode(’-’,$field);

split

Fred

items = “item1-item2-item2”.split(’-’)

And String#join for the reverse.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs