Mark Mr wrote: > Hi guys, I have a probably simple question. I dont know how to do > iteration loops in ruby that reference more than one item of an array or > more than one array. Here's an example of what I would do in php. Can > anyone convert this to ruby? Thanks :) > > while ($i=0; $i < $response_table.length; $i += 2) { > > <td> $response_table[$i] </td> > <td> $response_table[$i + 1] </td> > > } > > or something like this would work too if i made an array for questions > and a separate one for answers > > while ($i=0; $i < array_count; $i++) { > > <td> $question_table[$i] </td> > <td> $answer_table[$i] </td> > > } To make a similar loop to yours above you can use the times method. Like: response_table.size.times do |i| response_table[i] response_table[i+1] end question_table.size.times do |i| question_table[i] answer_table[i] end -- Posted via http://www.ruby-forum.com/.