modulo11 php

PHOTO EMBED

Sun Dec 27 2020 13:24:48 GMT+0000 (UTC)

Saved by @lynx74br #php

function modulo11 ($barcode)  {
  $sum = 0;
  for  ( $i=0; $i<=8; $i++ )  {
   $add = $barcode{$i} * ($i+1);
   $sum = $sum + $add; 
  }
  $modulo = $sum % 11;
  if ( $modulo == 10 )  { $modulo = "x"; }
  if ( $barcode{9} == $modulo ) {
   return true;
  } else {
   return false;
  }
} 
content_copyCOPY