Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:52:38+00:00 2026-05-28T17:52:38+00:00

The php code of barcode generator (which take from here http://www.barcodephp.com/en/userguide ) looks like

  • 0

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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:52:39+00:00Added an answer on May 28, 2026 at 5:52 pm

    Though I’ve never used the library before, it looks like you would just need to do the following:

    foreach ($barcodes as $barcode) {
        $code->parse($barcode);
        $drawing->setBarcode($code);
        $drawing->draw();
    }
    

    where $barcodes is an array containing your barcode numbers and the foreach is in the place of where your current $drawing->draw(); part is

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My .php code in a file fetchvalues.php looks like this: echo json_encode(array($PostedDate.Places.$Company.$Designation.$ProjectDetails.$DesiredCandidate.$HRName.$HRContact.$Email)); This file
My code structure is like this: some php code here... html head script some
my php code looks like this: $result['firstName']['lastName']='johan'; echo json_encode($result); how should i type to
PHP: Code: $category_searchresult = $db->db_query(SELECT category_code, category_name, category_comment FROM qa_categories WHERE .$search_by. LIKE '%.$search_string.%');
My php code looks like that if (isset($_REQUEST['term'])) { $term = trim(strip_tags($_REQUEST['term']));//retrieve the search
How do I configure php-barcode to generate code with the code128 encoding? I've installed
My PHP code looks as such: <a id='next_page' HREF='#' onclick=\javascript:document.getElementById('page_to_show').value=' . ($page + 1)
php code: <?php echo json_encode(glob(photos-.$_GET[folder].'/*.jpg')); ?> it return : [photos-animaux\/ani-01.jpg,photos-animaux\/ani-02.jpg,photos-animaux\/ani-02b.jpg,photos-animaux\/ani-03.jpg,photos-animaux\/ani-04.jpg,photos-animaux\/ani-05.jpg,photos-animaux\/ani-06.jpg,photos-animaux\/ani-07.jpg,photos-animaux\/ani-08.jpg,photos-animaux\/ani-09.jpg,photos-animaux\/ani-10.jpg,photos-animaux\/ani-11.jpg,photos-animaux\/ani-12.jpg,photos-animaux\/ani-13.jpg,photos-animaux\/ani-14.jpg] Which is ALMOST perfect,
This PHP code below fetches html from server A to server B. I did
This PHP code below will take an image and add the word _thumb in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.