function formatCnpjCpf($value)
{
$CPF_LENGTH = 11;
$cnpj_cpf = preg_replace("/\D/", '', $value);
if (strlen($cnpj_cpf) === $CPF_LENGTH) {
return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Possible values for ext-name: | |
| bcmath | |
| bz2 | |
| calendar | |
| ctype | |
| curl | |
| dba | |
| dom | |
| enchant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 80; | |
| server_name localhost; | |
| root /Users/YOUR_USERNAME/Sites; | |
| access_log /Library/Logs/default.access.log main; | |
| location / { | |
| include /usr/local/etc/nginx/conf.d/php-fpm; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Finalmente, agora eu tenho tudo quase perfeito com o Sublime, só me falta mesmo é um Outline para fechar de vez. | |
| Template para projetos Symfony: | |
| { | |
| "folders": | |
| [ | |
| { | |
| "path": ".", | |
| "folder_exclude_patterns": ["bundles", "assets", "cache"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Usage: <year-select offset=0 range=10 /> | |
| * | |
| */ | |
| app.directive('yearSelect',function(){ | |
| var currentYear = new Date().getFullYear(); | |
| return { | |
| restrict: 'AE', | |
| replace: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Para CPF | |
| /^\d{3}\.\d{3}\.\d{3}\-\d{2}$/ | |
| Para CNPJ | |
| /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/ | |
| Para ambos ao mesmo tempo |
NewerOlder