How to group dynamically generated content based on similar content
<p>I have a dynamically generated page with varying number of items (div.item). Each item has an inner div with class "date". The items are ordered by ascending order from the DB based on the date value. Since this page content taken from the DB there may be 10 items with the same date, then the next 3 will share a date, then the next X may share another date, and so on.</p>

<p>Based on the content of div.date I want to wrap all items with similar dates in a div.group. I would have preferred doing this direct on the PHP code, but I've inherited a large messy project with no documentation and this option is only temporary. The current simplified structure is below:</p>

<pre><code>&lt;div class="item"&gt;
  &lt;div class="date"&gt;04-06-2012&lt;/div&gt;
  &lt;div class="other-content"&gt;Other Content&lt;/div&gt;
&lt;/div&gt;
&lt;div class="item"&gt; // To be grouped with above
  &lt;div class="date"&gt;04-06-2012&lt;/div&gt; 
  &lt;div class="other-content"&gt;Other Content&lt;/div&gt;
&lt;/div&gt;
...
&lt;div class="item"&gt; // In it's own group
  &lt;div class="date"&gt;08-06-2012&lt;/div&gt;
  &lt;div class="other-content"&gt;Other Content&lt;/div&gt; 
&lt;/div&gt;
...
</code></pre>

<p>Thanks</p>
