Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/04/2015, 13:32
superweb360
(Desactivado)
 
Fecha de Ingreso: abril-2015
Ubicación: España
Mensajes: 616
Antigüedad: 9 años
Puntos: 74
Respuesta: Excluir numeros con rand

Código PHP:
Ver original
  1. $excluir = array(8,11,14,19);
  2. $numero = -1;
  3. while(true)
  4. {
  5.     $numero = rand(1,20);
  6.     if(!in_array($numero, $excluir))
  7.         break;
  8. }
  9. echo $numero;

Aunque este código, si hay muchos números a excluir, podría ser ineficiente.

Última edición por superweb360; 03/04/2015 a las 15:24