title: Loop through array and echo all child arrays that have same ID
body: <p>This is simplified version, I have an array filled with items and sometimes there could be duplicates</p>
  
  <pre><code>$items = array(
      array(
          'id' =&gt; 1,
          'title' =&gt; 'Item 1'
          ),
      array(
          'id' =&gt; 2,
          'title' =&gt; 'Item 2'
          ),
      array(
          'id' =&gt; 3,
          'title' =&gt; 'Item 3'
          ),
      array(
          'id' =&gt; 1,
          'title' =&gt; 'Item 1'
          ),
      array(
          'id' =&gt; 3,
          'title' =&gt; 'Item 1'
          ),
      array(
          'id' =&gt; 5,
          'title' =&gt; 'Item 5'
          ),
      array(
          'id' =&gt; 3,
          'title' =&gt; 'Item 1'
          ),
      );
  ?&gt;
  </code></pre>
  
  <p>What I need is to go through each item and echo its title but if there are more items with same ID in array, I need to echo their title side by current item and skip them later. </p>
  
  <pre><code>&lt;ul&gt;
      &lt;?php foreach($items as $item) : ?&gt;
          &lt;li&gt;
              &lt;?php echo $item['title']; ?&gt; 
              &lt;?php // check for other items and echo their titles if they are same
          &lt;/li&gt;
      &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>In the end, the example should come out like this</p>
  
  <pre><code>&lt;li&gt;Item 1 Item 1&lt;/li&gt;
  &lt;li&gt;Item 2&lt;/li&gt;
  &lt;li&gt;Item 3 Item 3 Item 3&lt;/li&gt;
  &lt;li&gt;Item 5&lt;/li&gt;
  </code></pre>
  
  <p>Any thoughts on how to solve it without making a mess? :)</p>
  
  <p>I was playing with stuff like this, somewhere echoes double lines.. generally not good</p>
  
  <pre><code>&lt;?php $int = 0; ?&gt;
  &lt;?php foreach($items as $item) : ?&gt;
      &lt;li&gt;
          &lt;?php 
          echo $item['title']; 
          $id = $item['id'];
          unset($items[$int]);
          $int++;
  
          foreach($items as $item_second) {
              if($item_second['id'] === $id) {
                  echo $item_second['title'];
                  unset($item_second);
              }
          }
          ?&gt;
      &lt;/li&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>