whats wrong with this foreach loop?
Posted: Thu Sep 18, 2008 4:19 pm
I have a list of 3 barcode numbers that are being extracted from the end of each of the following lines
sm_a6003.jpg, A6003 GUYCAN CASSAREEP CASSAVA 12X425GR,069065000295
sm_a6009.jpg, A6009 CHICO CASSAREEP POMEROON 24X425GR,069065000325
sm_a6012.jpg, A6012 BROWN BETTY CASSAREEP POMEROON 24X375ML,069065001322
i am using the foreach loop to go through each number and pass it to a variable called "$value" if the number is valid as a bar code number, the draw function is called to draw a bar code representing that number. After the bar code image has been created it is to be saved under that same number. for example if the bar code image was generated from this number 069065000332 then it would be saved as 069065000332.png
MY PROBLEM:
I am trying to go through the list and generate an image for each number but for some reason only the first number in the list is being used to generate multiple images which is wrong.
Can someone explane thanks in advance
here is the code
HERE IS the CODE
foreach ($data as $line) {
$temp = explode(",", $line);
$images=trim($temp[0]);
$descriptions=trim($temp[1]);
$value=trim($temp[2]);
if(isValid($value)==true){
Image_Barcode::draw($value, 'upca', 'png');
$png=".png";
$upc_image=$value.$png;
$File = $upc_image;
$Handle = fopen($File, 'w');
$Data = $barcode=ob_get_contents();
fwrite($Handle, $Data);
}
}
fclose($Handle);
sm_a6003.jpg, A6003 GUYCAN CASSAREEP CASSAVA 12X425GR,069065000295
sm_a6009.jpg, A6009 CHICO CASSAREEP POMEROON 24X425GR,069065000325
sm_a6012.jpg, A6012 BROWN BETTY CASSAREEP POMEROON 24X375ML,069065001322
i am using the foreach loop to go through each number and pass it to a variable called "$value" if the number is valid as a bar code number, the draw function is called to draw a bar code representing that number. After the bar code image has been created it is to be saved under that same number. for example if the bar code image was generated from this number 069065000332 then it would be saved as 069065000332.png
MY PROBLEM:
I am trying to go through the list and generate an image for each number but for some reason only the first number in the list is being used to generate multiple images which is wrong.
Can someone explane thanks in advance
here is the code
HERE IS the CODE
foreach ($data as $line) {
$temp = explode(",", $line);
$images=trim($temp[0]);
$descriptions=trim($temp[1]);
$value=trim($temp[2]);
if(isValid($value)==true){
Image_Barcode::draw($value, 'upca', 'png');
$png=".png";
$upc_image=$value.$png;
$File = $upc_image;
$Handle = fopen($File, 'w');
$Data = $barcode=ob_get_contents();
fwrite($Handle, $Data);
}
}
fclose($Handle);