protected function appendToArray(array $container, $key, $item) { if ($key === false) { $container[] = $item; return $container; } if (!isset($container[$key])) { $container[$key] = []; } $container[$key][] = $item; return $container; }