This article mainly introduces the php ID card number check class, which involves php Regular Expression matching and array traversal related skills. For more information, see
This article mainly introduces the php ID card number check class, which involves php Regular Expression matching and array traversal related skills. For more information, see
This example describes the php ID card number check class. Share it with you for your reference. The details are as follows:
<? Php class CIDMaker // declare an id card number check class {var $ id; var $ err; var $ idx = array,, 3,); var $ idy = array, ,); function check ($ id_no) {$ id_no = ucfirst ($ id_no ); // convert uppercase letters if (ereg ("^ [A-Z] [0-9] {9} $", $ id_no) {for ($ I = 0; $ I <10; $ I ++) $ ch [$ I] = substr ($ id_no, $ I, 1); $ I = 0; // convert English letters into numbers BEGINfor ($ char = "A"; $ char! = $ Ch [0]; $ char ++) $ I ++; // convert English letters to numbers END // import check formula BEGIN $ id = $ this-> idx [$ I] + $ this-> idy [$ I] * 9 + $ ch [1] * 8 + $ ch [2] * 7 + $ ch [3] * 6 + $ ch [4] * 5 + $ ch [5] * 4 + $ ch [6] * 3 + $ ch [7] * 2 + $ ch [8] * 1 + $ ch [9] * 1; $ id = ($ id % 10) = 0 )? TRUE: FALSE; return $ id; // import check formula END} elsereturn 0 ;}}?>
I hope this article will help you with php programming.
,