function BARCODE::_so25Encode in Barcode 6
1 call to BARCODE::_so25Encode()
File
- ./
barcode.inc.php, line 1120
Class
Code
function _so25Encode($barnumber) {
$encTable = array(
"NNWWN",
"WNNNW",
"NWNNW",
"WWNNN",
"NNWNW",
"WNWNN",
"NWWNN",
"NNNWW",
"WNNWN",
"NWNWN",
);
$guards = array(
"11011010",
"1101011",
);
$len = strlen($barnumber);
$barnumber = $this
->_checkDigit($barnumber, $len);
if ($len == strlen($barnumber) && substr($barnumber, -1) != '0') {
$barnumber .= '0';
}
$mfcStr = "";
$widebar = str_pad("", $this->_n2w, "1", STR_PAD_LEFT);
$widebar .= "0";
for ($i = 0; $i < strlen($barnumber); $i++) {
$num = (int) $barnumber[$i];
$str = "";
$str = str_replace("N", "10", $encTable[$num]);
$str = str_replace("W", $widebar, $str);
$mfcStr .= $str;
}
return $guards[0] . $mfcStr . $guards[1];
}