title: How to bundle PHP rows into collapsible form? (Elemental access to multidimensional array using next())
body: <p>I've got something like this:</p>
  
  <pre><code>while( $row = $result-&gt;fetch_assoc() ) {
          switch ($row["card_id"]) {
              case 0:
                  include 'card_0.php';
                  break;
              case 1:
                  include 'card_1.php';
                  break;
              case 2:
                  include 'card_2.php';
                  break;
              case 3:
                  include 'card_3.php';
                  break;
          }
  }
  </code></pre>
  
  <p>In the case that <code>card_id</code> is <code>1</code> I want to detect whether the next row's card_id is the same, and whether the next next row's card_id is the same and so on until I have them all and then put their associated field elements into an unordered list---as a bootstrap collapsible object. The whole idea here is that I don't want <code>card_1</code> events stacked right on top of each other. I want them to be collapsible. So, since my events are ordered by date they'll look like this:</p>
  
  <pre><code>card_0
  card_1
  card_1
  card_1
  card_3
  card_2
  card_2
  card_1
  card_1
  card_1
  card_1
  </code></pre>
  
  <p>I want it to look like this instead:</p>
  
  <pre><code>card_0
  CARD_1&lt;--clickable collapsible
  card_3
  card_2
  card_2
  CARD_1&lt;--clickable collapsible
  </code></pre>
  
  <p>I was thinking something like this:</p>
  
  <pre><code>while( $i == TRUE ) {
      while( current($row["card_id"]) == next($row["card_id"]) ) {
          $pea_pod[] = $row["field"];
          }
      $i = FALSE;
  }
  </code></pre>
  
  <p>Would that work?</p>