Loop Through Array Vertically

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?

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?

You can try something similar to this:

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

  foreach ($arr as $val) {

    echo $val->$field;



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