# Simple ERB question

**URL:** <https://discuss.rubyonrails.org/t/simple-erb-question/59202>\
**Category:** rubyonrails-talk\
**Created:** [May 26, 2011, 3:14pm UTC](https://discuss.rubyonrails.org/t/simple-erb-question/59202 "2011-05-26T15:14:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 26, 2011, 3:14pm UTC](https://discuss.rubyonrails.org/t/simple-erb-question/59202/1 "2011-05-26T15:14:29Z")

</div>

Hello, not sure if this should go here...

Trying to print out the contents of an array with a little bit of formatting

my array looks like this:

search = "[[67749303, 72756004, 178055737, 398925700, 551708624, 684936218, 846436579, 978955981]]"

search\_ary = search.split(",")

now in my erb view file I would like to print something like this to the html:

\<p\>67749303\</p\> \<p\>72756004\</p\> ....etc

what is the best way to do this???

---

<div class="post-metadata">

**Author:** ![Michael\_Pavling](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Michael\_Pavling](https://discuss.rubyonrails.org/u/Michael_Pavling)\
**Post date:** [May 26, 2011, 3:31pm UTC](https://discuss.rubyonrails.org/t/simple-erb-question/59202/2 "2011-05-26T15:31:32Z")

</div>

Not sure of the "best" way... but there are lots of ways - here's two:

You could render a collection of partials as described on [http://api.rubyonrails.org/classes/ActionView/Partials.html](http://api.rubyonrails.org/classes/ActionView/Partials.html)

You could loop yourself:

\<% search\_ary.each do |element| %\> &nbsp;&nbsp;\<%= content\_tag :p, element %\> \<% end %\>

By the way, did your example array mean to be nested in another array (two lots of square brackets...)?

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 26, 2011, 3:43pm UTC](https://discuss.rubyonrails.org/t/simple-erb-question/59202/3 "2011-05-26T15:43:39Z")

</div>

Assign your search array to an instance variable in your controller.

@search\_ary = search.split(",")

In your view do:

\<% @search\_ary.each do |row| %\> &nbsp;&nbsp;\<p\>\<%= row %\>\</p\> \<% end %\>

---

<div class="post-metadata">

**Author:** ![Sathia\_S](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Sathia\_S](https://discuss.rubyonrails.org/u/Sathia_S)\
**Post date:** [May 26, 2011, 3:47pm UTC](https://discuss.rubyonrails.org/t/simple-erb-question/59202/4 "2011-05-26T15:47:17Z")

</div>

> Hello, not sure if this should go here…
> 
> Trying to print out the contents of an array with a little bit of
> 
> formatting
> 
> my array looks like this:
> 
> search = "[[67749303, 72756004, 178055737, 398925700, 551708624,
> 
> 684936218, 846436579, 978955981]]"

\<% search.each do |number| %\>

\<%= number %\>

\<% end %\>

This will give result as below
