-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFormat.php
44 lines (41 loc) · 1.04 KB
/
Format.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class Format
{
//Funcao para formatar cgc tipo -> 99.999.999/9999-99
public static function formataCgc($numeros){
$count = 0;
$retorno = '';
if(strlen($numeros)==18){
$retorno = $numeros;
} else {
if(strlen($numeros)==14){
$retorno = substr($numeros, 0, 2).'.'.
substr($numeros, 2, 3).'.'.
substr($numeros, 5, 3).'/'.
substr($numeros, 8, 4).'-'.
substr($numeros, 12, 2);
} else {
$retorno = '';
}
}
return("$retorno");
}
//Funcao para formatar cpf tipo -> 999.999.999-99
public static function formataCpf($numeros){
$count = 0;
$retorno = '';
if(strlen($numeros)==14){
$retorno = $numeros;
} else {
if(strlen($numeros)==11){
$retorno = substr($numeros, 0, 3).'.'.
substr($numeros, 3, 3).'.'.
substr($numeros, 6, 3).'-'.
substr($numeros, 9, 2);
} else {
$retorno = '';
}
}
return("$retorno");
}
}