180 $str = preg_replace(
'/(\s)/',
'', $str);
181 $str = strtoupper($str);
184 if (!preg_match(
'/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $str)) {
189 for ($i = 0; $i < 9; $i++) {
190 $num[$i] = substr($str, $i, 1);
194 if (preg_match(
'/(^[0-9]{8}[A-Z]{1}$)/', $str)) {
195 if ($num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr($str, 0, 8) % 23, 1)) {
203 $sum = (int) $num[2] + (
int) $num[4] + (int) $num[6];
204 for ($i = 1; $i < 8; $i += 2) {
205 $sum += intval(substr((
string) (2 * (
int) $num[$i]), 0, 1)) + intval(substr((
string) (2 * (
int) $num[$i]), 1, 1));
207 $n = 10 - (int) substr((
string) $sum, strlen((
string) $sum) - 1, 1);
210 if (preg_match(
'/^[KLM]{1}/', $str)) {
211 if ($num[8] == chr(64 + $n) || $num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr($str, 1, 8) % 23, 1)) {
219 if (preg_match(
'/^[ABCDEFGHJNPQRSUVW]{1}/', $str)) {
220 if ($num[8] == chr(64 + $n) || $num[8] == substr((
string) $n, strlen((
string) $n) - 1, 1)) {
228 if (preg_match(
'/^[T]{1}/', $str)) {
229 if ($num[8] == preg_match(
'/^[T]{1}[A-Z0-9]{8}$/', $str)) {
237 if (preg_match(
'/^[XYZ]{1}/', $str)) {
238 if ($num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr(str_replace(array(
'X',
'Y',
'Z'), array(
'0',
'1',
'2'), $str), 0, 8) % 23, 1)) {