Skip to content

Instantly share code, notes, and snippets.

View otaciobarbosa's full-sized avatar
🍀
It's Ok To Be Different ✨

Otácio Barbosa otaciobarbosa

🍀
It's Ok To Be Different ✨
View GitHub Profile
@otaciobarbosa
otaciobarbosa / formatar_cnpj_cpf.md
Created August 19, 2020 06:02 — forked from davidalves1/formatar_cnpj_cpf.md
Função para formatar CNPJ e CPF, disponível em PHP e JS

PHP

function formatCnpjCpf($value)
{
  $cnpj_cpf = preg_replace("/\D/", '', $value);
  
  if (strlen($cnpj_cpf) === 11) {
    return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
  } 
  

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example