Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Gero o Hexadecimal */
- function randomHex() {
- $chars = 'ABCDEF0123456789';
- $color = '#';
- for ( $i = 0; $i < 6; $i++ ) {
- $color .= $chars[rand(0, strlen($chars) - 1)];
- }
- return $color;
- }
- // Dados Necessários Para o Sorteio...
- $nump='32'; // Numero de Participantes
- // Chamo a Funcao
- $sorteio=random($nump,1);
- function random($nNumeros, $nQuant) {
- $aRand = array();
- for ($i=1; $i<=$nQuant; $i++) {
- $aRand[$i] = $rand = randomHex();
- while (count($aRand) < $nNumeros)
- if (!in_array($rand, $aRand))
- $aRand[] = $rand;
- else
- $rand = randomHex();
- }
- return $aRand;
- }
- echo "<pre>";
- print_r($sorteio);
- echo "</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement