function UPC_checkdigit($str){
if(!preg_match('/^[0-9]{11,12}$/',$str))return;
for($i=0; $i<=10; $i++){
$digit+= $str[$i] * (!fmod($i,2) ? 3 : 1);
}
$digit=substr(500-$digit,-1);
if(strlen($str)==12){
return $digit==substr($str,-1);
}else{
return $digit;
}
}
wanted to share that with everyone. takes an 11 digit number and calculates the 12th digit according to the rules. saw this in VB and wanted to give it to folks in php