0
A matter of proof of logic
It is made from the sum of the 8 digits of the CEP, then subtract the result from the sum of the digits of the CEP of the multiple of 10 immediately superior to the result.
For example: CEP: 71010050 to 7 + 1 + 0 + 1 + 0 + 0 + 5 + 0 = 14 Subtract 14 out of 20. Validator = 6
I’ve done that part:
$cepCliente = "41600-610";
$cepClienteSemTraco = str_replace("-", "", $cepCliente);
$cepClienteArray = str_split($cepClienteSemTraco);
$cepClienteNumero01 = (int) $cepClienteArray[0];
$cepClienteNumero02 = (int) $cepClienteArray[1];
$cepClienteNumero03 = (int) $cepClienteArray[2];
$cepClienteNumero04 = (int) $cepClienteArray[3];
$cepClienteNumero05 = (int) $cepClienteArray[4];
$cepClienteNumero06 = (int) $cepClienteArray[5];
$cepClienteNumero07 = (int) $cepClienteArray[6];
$cepClienteNumero08 = (int) $cepClienteArray[7];
$cepClienteNumero09 = (int) $cepClienteArray[8];
$somaCep = $cepClienteNumero01+$cepClienteNumero02+$cepClienteNumero03+$cepClienteNumero04+$cepClienteNumero05+$cepClienteNumero06+$cepClienteNumero07+$cepClienteNumero08+$cepClienteNumero09;
The rest I can’t do
Zip code has no validation, this is inaccurate...the only thing you can verify is if it has 8 digits.
– Ivan Ferrer
@Ivanferrer It’s a matter of proof
– user138238
you can also take from the webservice of the mail, or the url, and treat the entry of that page:
https://viacep.com.br/ws/01001000/json/
– Ivan Ferrer