1, "b" => 2, "c" => 3, "d" => 4, "e" => 5, "f" => 6, "g" => 7, "h" => 8, "j" => 1, "k" => 2, "l" => 3, "m" => 4, "n" => 5, "p" => 7, "r" => 9, "s" => 2, "t" => 3, "u" => 4, "v" => 5, "w" => 6, "x" => 7, "y" => 8, "z" => 9 ); $sum = 0; for($i = 0 ; $i < strlen($vin) ; $i++ ) { // loop through characters of VIN // add transliterations * weight of their positions to get the sum $check_char = substr($vin, $i, 1); if(!is_numeric($check_char)) { $sum += $transliterations[$check_char] * $weights[$i]; } else { $sum += $check_char * $weights[$i]; } } // find checkdigit by taking the mod of the sum $checkdigit = $sum % 11; if($checkdigit == 10) { // checkdigit of 10 is represented by "X" $checkdigit = "x"; } $actual_checkdigit = substr($vin, 8, 1); return ($checkdigit == $actual_checkdigit); } //------------------------------------------ //-------- END -------------------------- //------------------------------------------ //GET WMI - world manufacturer ID function getWMI($vin){ //WMI = first 3 digits $wmi = substr($vin, 0, 3); return $wmi; } // VDS - vehicle descriptor function getVDS($vin){ //WMI = first 3 digits $vds = substr($vin, 3, 5); return $vds; } // VIS - serialnumber function getVIS($vin){ //WMI = first 3 digits $vis = substr($vin, 9, 8); return $vis; } // Get the manufacturing country of the vehicle function getCountry($wmi) { include './settings/settingsvin.php'; return $countries[substr($wmi, 0, 2)] ?? 'Unknown'; } // Get the manufacturer of the vehicle function getManufacturer($wmi) { include './settings/settingsvin.php'; return $manufacturers[$wmi] ?? 'Unknown'; } function getYear($vis){ include './settings/settingsvin.php'; //first character = year return $years[substr($vis, 0, 1)] ?? 'Unknown'; } // Check if get_content has 17 characters, then expect VIN if (strlen($get_content) == 17){ $vin = strtoupper($get_content); $messages = [ "VIN" => $vin, "Manufacturer" => getManufacturer(getWMI($vin)), "year" => getYear(getVIS($vin)) ]; } else { $messages = [ "VIN" => $vin, "Manufacturer" => "Unknown", "year" => "Unknown" ]; } //------------------------------------------ //JSON_ENCODE //------------------------------------------ $messages = json_encode($messages, JSON_UNESCAPED_UNICODE); //Send results echo $messages; ?>