Views: Apply a wrapper to every 3 and 6 group of rows
A few tips about the code:


You also can make the logic in the preproccess or proccess hooks if you prefer
To complete the information given by Jack: Modular arithmetic . This theory help us to build our strategy.


Aplication in a preprocces hook to separate the logic from the template:

function YOURTHEME_preprocess_views_view_unformatted(&amp;$vars){

   $vars['prefix'] = array();
   $vars['suffix'] = array();
   $group = 1;
   $last_row = count($vars['rows']) -1;

   foreach($vars['rows'] as $id =&gt; &amp;$row){

     $vars['prefix'][$id] = '';
     $vars['suffix'][$id] = '';

     // Apply modular arithmetic
     $remainder = $id % 9;

     // First div =&gt; 3 items
     if($remainder == 0){
       $vars['prefix'][$id] = "\n &lt;div class=\"group group-$group\"&gt;";
     }

     if($remainder == 2){
       $vars['suffix'][$id] = '\n &lt;/div&gt;';
       $group++;
     }

     // Second item =&gt; 6 items
     if($remainder == 3){
       $vars['prefix'][$id] = "\n &lt;div class=\"group group-$group\"&gt;";
     }

     if($remainder == 8){
       $vars['suffix'][$id] = '\n &lt;/div&gt;';     
       $group++;
     }

     // Close the div in case there are not enough items
     if($last_row == id &amp;&amp; $remainder != 2 &amp;&amp; $remainder != 8){
        $vars['suffix'][$id] = '\n &lt;/div&gt;';
     }

   }

}


Your template in you theme that will overwrite the default template provided by views:

&lt;?php if (!empty($title)): ?&gt;
  &lt;h3&gt;&lt;?php print $title; ?&gt;&lt;/h3&gt;
&lt;?php endif; ?&gt;
&lt;?php foreach ($rows as $id =&gt; $row): ?&gt;
  &lt;?php if (!empty($prefix[$id])){ print $prefix[$id]; } ?&gt;
    &lt;div &lt;?php if ($classes_array[$id]) { print 'class="' . $classes_array[$id] .'"';  } ?&gt;&gt;
    &lt;?php print $row; ?&gt;
  &lt;?php if (!empty($suffix[$id])){ print $suffix[$id]; } ?&gt;
&lt;/div&gt;
&lt;?php endforeach; ?&gt;