pivot a table

Hello,

I am trying to pivot a table but cannot figure out how. Any help appreciated.

Current format is as follows:


visit_id   |  question_id   |    score (a number between 1 and 10)

=======================================

visit_1    |  service       |    8

visit_1    |  menu          |    8

visit_2    |  service       |    5

visit_2    |  menu          |    7

I want to create the following array output:


[0]

  visit_id => visit_1

  service => 8

  menu => 8

[1]

  visit_id => visit_2

  service => 5

  menu => 7

Any help appreciated

Thanks