Created
January 14, 2025 20:08
-
-
Save globalideias/441d9fcdc45607c0592e11174e418ec2 to your computer and use it in GitHub Desktop.
Função para criar um código único de 20 caracteres que pode ser usado para vouchers ou cupons.
This file contains 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
<?php | |
function code_unique_20() | |
{ | |
$letras = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z']; | |
$numeros = time(); | |
$cadeia = []; | |
$offset = 2; | |
for ($i = 0; $i < 5; $i++) { | |
$cadeia[$i] = $letras[rand(0, 24)] . substr($numeros, ($i * $offset), $offset) . $letras[rand(0, 24)]; | |
} | |
shuffle($cadeia); | |
return join("-", $cadeia); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Saida exemplo: Y36T-D50Z-K88N-A26A-E17F