title: credit card validation using Luhn's
body: <p>I was working on a credit card validation using Luhn's algorithm: I just need to see if the number is a valid credit card number.</p>
  
  <pre><code>$number=clean($_GET['number']);
  if (LuhnCheck($number) == 0)
  {
     echo "credit card valid";
  }
  else
  {
     echo "invalid";
  }
  
   function LuhnCheck($strDigits)
      {
          $sum = 0;
          $alt = false;
          for($i = strlen($strDigits) - 1; $i &gt;= 0; $i--) 
          {
              if($alt)
              {
                 $temp = $strDigits[$i];
                 $temp *= 2;
                 $strDigits[$i] = ($temp &gt; 9) ? $temp = $temp - 9 : $temp;
              }
              $sum += $strDigits[$i];
              $alt = !$alt;
          }
          return $sum % 10 == 0;
      }
  </code></pre>
  
  <p>Will the above work for AMEX,discover,visa and mastercard? I am unable to confirm.</p>