I'm looping through some results list that contains information about fruit and who has picked.
Each iteration contains a single fruit and a single person who picked it.
foreach($Jobs as $key => $val) {
//set values
$fruit = $val->FruitName;
$picker = $val->Picker->ForeName;
//build my array here
$myArray[$val->FruitName] = $val->Picker->ForeName;
}
I'm trying to build up an associative array (using fruit names) that holds an array of the picker names, like so;
$myArray = array (
"apple" => array ("Jon","Jo","Dave"),
"pear" => array ("Ben"),
"plumb" => array ("Jane"),
"melon" => array ("Jon","Jo","Dave","Sarah"),
);
The way I'm currently attempting this simply overwrites the existing array of picker names.