title: How to avoid duplicating strings in a row created by foreach loop?
body: <p>After trying some methods without success, I must give up, and ask this here. </p>
  
  <p>So I have an array <strong>$product_var_tpl_list = array();</strong> the output looks like this:</p>
  
  <pre><code>Shop1m  |  Pruduct 12  
  Shop1m  |  Product 366 
  Shop1m  |  Product 66 
  Shop3a  |  Product 89 
  Shop3a  |  Product 5   
  Shop55  |  Product 6  
  </code></pre>
  
  <p>I want to avoid dublicating strings from column 1 - the output must be like this:</p>
  
  <pre><code>Shop1m  |  Pruduct 12  
          |  Product 366
          |  Product 66  
  Shop3a  |  Product 89 
          |  Product 5  
  Shop55  |  Product 6  
  </code></pre>
  
  <p>The PHP code is:</p>
  
  <pre><code>                    $product_var_tpl_list = array();
                      foreach ($order-&gt;product_list as $product) {
                          $price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order-&gt;id_customer, (int)$order-&gt;id_cart, (int)$order-&gt;{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                          $price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order-&gt;id_customer, (int)$order-&gt;id_cart, (int)$order-&gt;{Configuration::get('PS_TAX_ADDRESS_TYPE')});
  
                          $product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
  
                          //here is data about the seller
                          $idProduct = (int)$product['id_product'];
                          $SellerInfoOverride = Db::getInstance()-&gt;executeS('SELECT * FROM `'._DB_PREFIX_.'wk_mp_seller_product`  WHERE `id_ps_product` = '.(int) $idProduct);
                          foreach ($SellerInfoOverride as $key =&gt; $value) {
                              $sellerid = $value['id_seller'];
                              //$seller = $mpSeller-&gt;getSeller($value['id_seller'], $this-&gt;context-&gt;language-&gt;id);
                              $SellerInfoDetails = Db::getInstance()-&gt;executeS('SELECT * FROM `'._DB_PREFIX_.'wk_mp_seller`  WHERE `id_seller` = '.(int) $sellerid);
                              foreach ($SellerInfoDetails as $key =&gt; $value) {
                                  $seller_name = $value['shop_name_unique'];
                              }
                          }
  
                          $product_var_tpl = array(
  
                              'reference' =&gt; $seller_name,
                              'name' =&gt; $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
                              'unit_price' =&gt; Tools::displayPrice($product_price, $this-&gt;context-&gt;currency, false),
                              'price' =&gt; Tools::displayPrice($product_price * $product['quantity'], $this-&gt;context-&gt;currency, false),
                              'quantity' =&gt; $product['quantity'],
                              'customization' =&gt; array()
  
                          );
  
  
                          $customized_datas = Product::getAllCustomizedDatas((int)$order-&gt;id_cart);
                          if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
                              $product_var_tpl['customization'] = array();
                              foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order-&gt;id_address_delivery] as $customization) {
                                  $customization_text = '';
                                  if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
                                      foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
                                          $customization_text .= $text['name'].': '.$text['value'].'&lt;br /&gt;';
                                      }
                                  }
  
                                  if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
                                      $customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'&lt;br /&gt;';
                                  }
  
                                  $customization_quantity = (int)$product['customization_quantity'];
  
                                  $product_var_tpl['customization'][] = array(
                                      'customization_text' =&gt; $customization_text,
                                      'customization_quantity' =&gt; $customization_quantity,
                                      'quantity' =&gt; Tools::displayPrice($customization_quantity * $product_price, $this-&gt;context-&gt;currency, false)
                                  );
                              }
                          }
  
                          $product_var_tpl_list[] = $product_var_tpl;
                          // Check if is not a virutal product for the displaying of shipping
                          if (!$product['is_virtual']) {
                              $virtual_product &amp;= false;
                          }
                      } // end foreach ($products)
  
                      // this will sort the output by alphabetical order based on reference value
                      usort($product_var_tpl_list, function($a, $b) {  
                              return strcmp($a['reference'], $b['reference']);
                      });
  </code></pre>