title: PHP How to print barcode in 2 columns zebra prn code
body: <p>I am stuck in coding, unable to get solution. I have PHP code which print barcode in zebraGC420T printer using prn code. I have attached prn file too. Everything is working fine, but getting double print for each print given.</p>
  
  <p>For example, if I have to print 2 labels, it will print 4 lables and if I need to print 4 labels it will 16 labels. I know some where I have to add logic, so I need your suggestions to complete the code, please help me.</p>
  
  <pre><code>foreach ($barcodes as $item) {
      for ($r = 1; $r &lt;= $item['quantity']; $r++) {
  
          $p = $item['quantity'];
          echo $p;
  
          //Label First///                                        
          $label .= "N\n";
          $label .= "A580,175,2,2,2,2,N,"."'.$item[site].'\n";
          $label .= "B586,68,2,1,2,6,40,B,"."'.$item[name].'\n";
          $label .= "A590,137,2,4,1,1,N,"."'.$item[name].'\n";                                        
          $label .= "A599,102,2,4,1,1,N,"."MRP\n";
          $label .= "A550,113,2,3,2,2,N,"."'.$item[price].'\n";
  
          //Label Second///
          $label .= "A275,175,2,2,2,2,N,"."'.$item[site].'\n";
          $label .= "B281,68,2,1,2,6,40,B,"."'.$item[name].'\n";
          $label .= "A285,137,2,4,1,1,N,"."'.$item[name].'\n";
          $label .= "A294,102,2,4,1,1,N,"."MRP\n";
          $label .= "A245,113,2,3,2,2,N,"."'.$item[price].'\n";
          $label .= "P1\n";
          $label .= '\n';
      }
  $r++
  </code></pre>
  
  <p>Sample Barcode Design - <a href="https://www.dhresource.com/webp/m/0x0s/f2-albu-g3-M00-E4-05-rBVaHFYzWP-ABP9XAACXAOlRpWk369.jpg/glossy-white-pet-label-sticker-35mm-x-8mm.jpg" rel="nofollow noreferrer">https://www.dhresource.com/webp/m/0x0s/f2-albu-g3-M00-E4-05-rBVaHFYzWP-ABP9XAACXAOlRpWk369.jpg/glossy-white-pet-label-sticker-35mm-x-8mm.jpg</a></p>
  
  <p>This is how I print to file and send it to barcode printer using dos command, every thing is fine, just not printing correct nos..</p>
  
  <pre><code>$current = file_get_contents($file);
  $label  = "Q203,024\n";
  $label .= "q831\n";
  $label .= "rN\n";
  $label .= "S5\n";
  $label .= "D10\n";
  $label .= "ZT\n";
  $label .= "JF\n";
  $label .= "O\n";
  $label .= "R109,0\n";
  $label .= "f100\n";
  $label .= "N\n";
  $label .= "A580,175,2,2,2,2,N,"."'POSSHINE'\n";
  $label .= "B586,68,2,1,2,6,40,B,"."'1234567'\n";
  $label .= "A590,137,2,4,1,1,N,"."'Lee Jeans'\n";
  $label .= "A599,102,2,4,1,1,N,"."MRP\n";
  $label .= "A550,113,2,3,2,2,N,"."'Rs.899'\n";
  $label .= "A275,175,2,2,2,2,N,"."'Posshine'\n";
  $label .= "B281,68,2,1,2,6,40,B,"."'1234567'\n";
  $label .= "A285,137,2,4,1,1,N,"."'Lee Jeans'\n";
  $label .= "A294,102,2,4,1,1,N,"."MRP\n";
  $label .= "A245,113,2,3,2,2,N,"."'Rs.899'\n";
  $label .= "P1\n";
  $label .= '\n';
  $current = $label;
  file_put_contents($file, $current."\n", FILE_APPEND);
  </code></pre>