The php credit card number verification function describes a php credit card number verification function that can verify whether a card number is a credit card. & Nbsp; functionvalidateCard ($ cardnumber) {$ cardnumberpreg_replace (& quot; D | s & quot;, & quot;, $ cardnumber); $ cardl php credit card number verification function
Describes a php credit card number verification function to verify whether a card number is a credit card.
Function validateCard ($ cardnumber) {$ cardnumber = preg_replace ("/\ D | \ s/", "", $ cardnumber); $ cardlength = strlen ($ cardnumber ); if ($ cardlength! = 0) {$ parity = $ cardlength % 2; $ sum = 0; for ($ I = 0; $ I <$ cardlength; $ I ++) {$ digit = $ cardnumber [$ I]; if ($ I % 2 = $ parity) $ digit = $ digit * 2; if ($ digit> 9) $ digit = $ digit-9; $ sum = $ sum + $ digit;} $ valid = ($ sum % 10 = 0); return $ valid;} return false ;}
Article Excerpt: php credit card number verification function