# Ruby alternative to php's implode and expload functions

**URL:** <https://www.ruby-forum.com/t/ruby-alternative-to-phps-implode-and-expload-functions/70362>\
**Category:** Rails\
**Created:** [September 28, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/ruby-alternative-to-phps-implode-and-expload-functions/70362 "2006-09-28T18:15:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mmaki](https://www.ruby-forum.com/u/mmaki)\
**Post date:** [September 28, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/ruby-alternative-to-phps-implode-and-expload-functions/70362/1 "2006-09-28T18:15:34Z")

</div>

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);

---

<div class="post-metadata">

**Author:** ![mmaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mmaki](https://www.ruby-forum.com/u/mmaki)\
**Post date:** [September 28, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/ruby-alternative-to-phps-implode-and-expload-functions/70362/2 "2006-09-28T18:21:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mmaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mmaki](https://www.ruby-forum.com/u/mmaki)\
**Post date:** [September 28, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/ruby-alternative-to-phps-implode-and-expload-functions/70362/3 "2006-09-28T18:24:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mmaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mmaki](https://www.ruby-forum.com/u/mmaki)\
**Post date:** [September 28, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/ruby-alternative-to-phps-implode-and-expload-functions/70362/4 "2006-09-28T18:24:48Z")

</div>

And String#join for the reverse.
