$fruits['red'][ ] = 'strawberry';
$fruits['red'][ ] = 'apple';
$fruits['yellow'][ ] = 'banana';
Or, if you're processing items in a loop:
while (list($color,$fruit) = mysql_fetch_array($r)) {
$fruits[$color][ ] = $fruit;
}
To print the entries, loop through the array:
foreach ($fruits as $color=>$color_fruit) {
// $color_fruit is an array
foreach ($color_fruit as $fruit) {
print "$fruit is colored $color.<br>";
}
}