Hello in Brazil with a number of national registration.
CPF - Cadastro Pessoa Fisica (Registration of Individual)
This number is present in any register of basic personal forms.
His mask is 000.000.000-00
where the 2 latest numbers validate the 9 first

Their size can easily be validated by the regular expression
^ ((\ d (3)) \.) (2) (\ d (3)) - (\ d (2)) $

  - The answer format
  - Must be unique in the Vineyard
  - Validate the algorithm


I wonder how you can create an automatic validation for new forms with
these patterns 3



I appreciate any help


the algorithm:

   $nro = $cpf;
   $s = "";
   for($x = 1; $x <= strlen($nro); $x++)
      {
         $ch = substr($nro,$x-1,1);
         if(ord($ch) >= 48 && ord($ch) <= 57)
           {
              $s = $s . $ch;
           }
      }
   $nro = $s;
   if( (strlen($nro) != 11) || ($nro=="00000000000") ||
($nro=="11111111111") ||
      ($nro=="22222222222") || ($nro=="33333333333") ||
($nro=="44444444444") ||
      ($nro=="55555555555") || ($nro=="66666666666") ||
($nro=="77777777777") ||
      ($nro=="88888888888") || ($nro=="99999999999"))
     {
        return false;
     }
    else
     {
        $Numero[1]  = intval(substr($nro,1-1,1));
        $Numero[2]  = intval(substr($nro,2-1,1));
        $Numero[3]  = intval(substr($nro,3-1,1));
        $Numero[4]  = intval(substr($nro,4-1,1));
        $Numero[5]  = intval(substr($nro,5-1,1));
        $Numero[6]  = intval(substr($nro,6-1,1));
        $Numero[7]  = intval(substr($nro,7-1,1));
        $Numero[8]  = intval(substr($nro,8-1,1));
        $Numero[9]  = intval(substr($nro,9-1,1));
        $Numero[10] = intval(substr($nro,10-1,1));
        $Numero[11] = intval(substr($nro,11-1,1));

        $soma = 10*$Numero[1]+9*$Numero[2]+8*$Numero[3]+7*$Numero[4]+6*
$Numero[5]+5*$Numero[6]+4*$Numero[7]+3*$Numero[8]+2*$Numero[9];
        $soma = $soma - (11 * (intval($soma / 11)));
        if($soma == 0 || $soma == 1)
          {
             $resultado1 = 0;
          }
        else
          {
             $resultado1 = 11 - $soma;
          }
        if($resultado1 == $Numero[10])
          {
             $soma = $Numero[1]*11+$Numero[2]*10+$Numero[3]*9+
$Numero[4]*8+$Numero[5]*7+$Numero[6]*6+$Numero[7]*5+$Numero[8]*4+
$Numero[9]*3+$Numero[10]*2;
             $soma = $soma - (11 * (intval($soma / 11)));
             if($soma == 0 || $soma == 1)
               {
                  $resultado2 = 0;
               }
             else
               {
                  $resultado2 = 11 - $soma;
               }
             if($resultado2 == $Numero[11])
               {
                  return true;
               }
             else
               {
                  return false;
               }
          }
        else
          {
             return false;
          }
     }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to