The title of the question might hard to interpret, the following is the code that might help
$containers = array(); // array of arrays
for ($index = 0; $index < 4; $index++) {
$containers[] = array(); // each element of the array is an array
}
foreach ($objects as $object) {
$index = computeIndex($object); // compute the index into the $containers
$container = $containers[$index]; // get the subarray object
$container[] = $object; // append $object to the end of the subarray
$containers[$index] = $container; // <--- question: is this needed?
}
So as the question shows, do I still need to reassign the subarray back to the array? If its a reference of the element in the array, then I don't think I need.