title: How to compare values in a loop?
body: <p>I have orders come in. Each order has a type i.e 'Vanilla' and a size i.e 'Mini with a quantity.</p>
  
  <p>If there are 5 Mini Vanillas I want it to display once not 5 times. I also want to tally the quantity.</p>
  
  <p>Here is one of the many things I attempted</p>
  
  <pre><code>$prevSize = null;
  $prevType= null;
  
  foreach ($orders as $order){
  echo '&lt;tr&gt;';
  $new_order = new WC_Order();
      $order_items = $new_order-&gt;get_items();
  
    foreach ($order_items as $order_item ){
    $currentSize = $order_item['pa_size'];
    $currentType = wp_get_post_terms( $order_item['product_id'],'pa_ct');
    $currentType = $currentType[0]-&gt;name;
  
    if($prevSize != $currentSize){
      echo $currentType . '&lt;br&gt;';
      echo $currentSize . '&lt;br&gt;';
    }
      $count += $order_item['qty'];
      echo $count;
   }
    $prevSize = $currentSize;
    $prevType = $currentType;}
  </code></pre>