Skip to content

Instantly share code, notes, and snippets.

View carlosalbertocruz's full-sized avatar

Carlos Alberto carlosalbertocruz

View GitHub Profile
@carlosalbertocruz
carlosalbertocruz / validar_cpf.php
Created August 26, 2018 21:51 — forked from rafael-neri/validar_cpf.php
Validar CPF em PHP (Completo)
<?php
function validaCPF($cpf) {
// Extrai somente os números
$cpf = preg_replace( '/[^0-9]/is', '', $cpf );
// Verifica se foi informado todos os digitos corretamente
if (strlen($cpf) != 11) {
return false;
@carlosalbertocruz
carlosalbertocruz / URL Amigável
Created July 30, 2018 12:13 — forked from cagartner/URL Amigável
Função para criar url amigável PHP
static function urlAmigavel($nom_tag,$slug="-") {
$string = strtolower($nom_tag);
// Código ASCII das vogais
$ascii['a'] = range(224, 230);
$ascii['e'] = range(232, 235);
$ascii['i'] = range(236, 239);
$ascii['o'] = array_merge(range(242, 246), array(240, 248));
$ascii['u'] = range(249, 252);