function FormataCep($aux){ $s=""; for ($x=1; $x<=strlen($aux); $x=$x+1){ $ch=substr($aux,$x-1,1); if (ord($ch)>=48 && ord($ch)<=57){ $s=$s.$ch; } } if(strlen($s)!=8) return False; $cep=substr($s,0,5); $cep.="-"; $cep.=substr($s,5); return $cep; }