Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. function Controle($NumeroTrain)
  3. {
  4.   $while = 0;
  5.   $ARRAY = str_split($NumeroTrain);
  6.   $result = 0;
  7.   $while = 0;
  8.   $arraycount = count($ARRAY);
  9.  
  10.   $arrayget = 0;
  11.   $array1 = 1;
  12.  
  13.   while ($arraycount != $while)
  14.   {
  15.     $while++;
  16.     if ( $array1 & 1 )
  17.     {
  18.       $two = $ARRAY[$arrayget];
  19.       $two = 2*$two;
  20.       if ( $two >= 10)
  21.       {
  22.         $two = $two-9;
  23.       }
  24.       $result = $result+$two;
  25.       echo "<br>REs : $result</br>";
  26.     }
  27.     else
  28.     {
  29.       $one = $ARRAY[$arrayget];
  30.       $result = $result+$one;
  31.       echo "<br>REs : $result</br>";
  32.     }
  33.     $arrayget++;
  34.     $array1++;
  35.   }
  36.   $arraytotal = ceil($result/10)*10;
  37.   $result = $arraytotal-$result;
  38.   return $result;
  39. }
  40. $NumeroTrain = '51800843004';
  41. $result = Controle($NumeroTrain);
  42. echo $result;
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement