so my code at the moment is checking a UPC barcode (which is found to be valid via some maths, and if the outcome of the maths is equal to the last digit then, its valid), and in the equations you have to ignore the last digit, and at the moment, my code doing that is then ignoring any numbers that are the same as the final number (the check number). Here is a snippet of my code:
Code:
$oddNums = array();
$evenNums = array();
$barcode = '123456789999';
$check = $barcode[strlen($barcode)-1];
for($i = 0; $i <= strlen($barcode); $i++){
$focus = $barcode[$i];
if(($i == 0 || ($i % 2) == 0) && $focus != $check){
array_push($oddNums, $focus);
}
if(($i == 1 || (($i % 2) != 0)) && $focus != $check){
array_push($evenNums, $focus);
}
}
Bookmarks