Loop Through Array Vertically

(Micho23) #1

I have an array which contains data retrieved from a database table.

I know that I can retrieve the values by a normal foreach loop like this which is then going through the array row by row.

However, I am using a jquery plugin which requires me to print out the values vertically instead. I’m trying this:

This is not working. Any ideas?

(Kburton) #2

I’m not quite sure what you’re asking and it’s not clear from the code how your data is structured or what you’re trying to do. Can you try to explain it again?

(Yii) #3

You can try something similar to this:

foreach (array('date', 'hour1', 'hour2') as $field) {

  foreach ($arr as $val) {

    echo $val->$field;



(Micho23) #4

Thank you so much Rodrigo. That was exactly what I needed.