PHP Classes

ean8

Recommend this page to a friend!

      ean13  >  All threads  >  ean8  >  (Un) Subscribe thread alerts  
Subject:ean8
Summary:What changes are needed
Messages:1
Author:Joe
Date:2015-01-23 10:24:12
 

  1. ean8   Reply   Report abuse  
Picture of Joe Joe - 2015-01-23 10:24:12
Hi, this class works great. Thank you!

I tried to change it to generate ean8 codes but failed.
I have this, if you can help please...:

function Code8($ean) {
$string = substr($ean,0,1).chr(65 + substr($ean,1,1));
$first = substr($ean,0,1);
for ($i=3; $i<=5; $i++) {
$in_a = false;
switch ($i) {
case 3:
$in_a = in_array($first, array(0, 1, 2, 3)) ? true : false;
break;
case 4:
$in_a = in_array($first, array(0, 4, 7, 8)) ? true : false;
break;
case 5:
$in_a = in_array($first, array(0, 1, 4, 5, 9)) ? true : false;
break;
case 6:
$in_a = in_array($first, array(0, 2, 5, 6, 7)) ? true : false;
break;
case 7:
$in_a = in_array($first, array(0, 3, 6, 8, 9)) ? true : false;
break;
}
if ($in_a) {
$string = $string.chr(65 + substr($ean, ($i-1), 1));
} else {
$string = $string.chr(75 + substr($ean, ($i-1), 1));
}
}
$string = $string.'*';
for ($i=6; $i<=8; $i++) {
$string = $string.chr(97 + substr($ean, ($i-1), 1));
}
$string = $string.'+';
return $string;
}
?>

 
For more information send a message to info at phpclasses dot org.