The php code of barcode generator (which take from here http://www.barcodephp.com/en/userguide) looks like that.
I can’t figure out which part must be inside foreach loop to generate multiple barcodes from array? $code->parse('1'); // Text this line gets 1 value – in this case number 1 and generates barcode. I need to generate barcode for all elements of number array
// Including all required classes
require_once('incl/class/BCGFontFile.php');
require_once('incl/class/BCGColor.php');
require_once('incl/class/BCGDrawing.php');
// Including the barcode technology
require_once('incl/class/BCGcode39.barcode.php');
// Loading Font
$font = new BCGFontFile('./incl/class/font/Arial.ttf', 18);
// The arguments are R, G, B for color.
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
$drawException = null;
try {
$code = new BCGcode39();
$code->setScale(2); // Resolution
$code->setThickness(30); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
$code->parse('1'); // Text
} catch(Exception $exception) {
$drawException = $exception;
}
/* Here is the list of the arguments
1 - Filename (empty : display on screen)
2 - Background color */
$drawing = new BCGDrawing('', $color_white);
if($drawException) {
$drawing->drawException($drawException);
} else {
$drawing->setBarcode($code);
$drawing->draw();
}
// Header that says it is an image (remove it if you save the barcode to a file)
header('Content-Type: image/png');
// Draw (or save) the image into PNG format.
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
Though I’ve never used the library before, it looks like you would just need to do the following:
where $barcodes is an array containing your barcode numbers and the foreach is in the place of where your current
$drawing->draw();part is