Php – storing db contents in array PHP

PHP

I am not sure how to do this, but if it can be done can anyone please help me in this.
Basically I have 3 columns in my table:

ID Set   Result Case  
1  Set1  PASS   101  
2  Set2  FAIL   102  
3  Set2  FAIL   101  
4  Set1  FAIL   101  
5  Set1  PASS   104  

$set =  $row['Set'];

What I am trying to achieve is , foreach of these Set, store its associated Result and Case in an array.

Best Answer

$arr = array();

foreach ($records as $key => $value)
{
    $arr[$key]['Result'] = $value['Result'];
    $arr[$key]['Case'] = $value['Case'];
}

echo '<pre>';
print_r($arr);
echo '</pre>';

In light of your comment:

foreach ($records as $key => $value)
{
    $arr[$key][$value['Result']] = $value['Case'];
}

In light of your most recent comment:

foreach ($records as $key => $value)
{
    $arr[$value['Set']][$value['Result']] = $value['Case'];
}