We don't have a $type when calling is_valid_barcode.
I have been trying this:
function is_valid_barcode($code)
{
$types = array("EAN2", "EAN5", "EAN8", "EAN13", "UPCA", "UPCE", "C39", "C39+", "C39E", "C39E+", "I25",
"C128A", "C128B", "C128C", "POSTNET", "CODABAR");
foreach ($types as $type)
{
if (substr($type, 0, 3) === "EAN" || substr($type, 0, 3) == "UPC")
{
if (!preg_match("/^[0-9]+$/", $code))
continue;
}
$barcode = new TCPDFBarcode($code, $type);
$chk = $barcode->getBarcodeArray();
if ($chk !== false)
return true;
}
return false;
}
But if alphanumerical characters it is still testing. It shouldn't if EAN of UPC. Please try it.
Maybe I have overseen something, so please help.
/Joe