Ver Mensaje Individual
  #5 (permalink)  
Antiguo 27/02/2015, 16:49
Avatar de informacionsys
informacionsys
 
Fecha de Ingreso: mayo-2011
Ubicación: Bogota D.C
Mensajes: 793
Antigüedad: 13 años
Puntos: 76
Respuesta: Combinaciones de números aleatorios que no se repitan

hola..

esta es una idea para que te guies...

Código PHP:
Ver original
  1. function getCartones()
  2. {
  3.     $fnNumbers = function()
  4.     {  
  5.         for($i2 = 1 ; $i2  <= 99 ; $i2++)
  6.         {
  7.             $n[] = $i2;
  8.         }
  9.         return $n;
  10.     };
  11.  
  12.     $numbers     = $fnNumbers();//arreglo con los numeros aleatorios posibles  
  13.     $totCartones = floor(count($numbers)/15);   //cantidad de cartones a crear
  14.  
  15.     function fnCarton($list,$numbers=array())
  16.     {  
  17.         if(!empty($numbers))
  18.         {
  19.             for($row = 1 ; $row <= 15 ; $row++)
  20.             {
  21.                 $nro  = array_rand($numbers,1);
  22.  
  23.                 if(in_array($nro,$numbers) && !empty($nro))
  24.                 {
  25.                     $list[] = $nro;
  26.                     $key    = array_search($nro,$numbers);
  27.                     unset($numbers[$key]);
  28.                 }
  29.  
  30.                 if(count($list) < 15 )
  31.                 {
  32.                    return fnCarton($list,$numbers);
  33.                 }
  34.                 else
  35.                 {
  36.                     return $list;
  37.                 }
  38.             };//fin for            
  39.         }
  40.     }; 
  41.  
  42.     for($ic = 0 ; $ic < $totCartones ; $ic++)
  43.     {
  44.         $list           = array();//arreglo con los 15 numeros posibles por carton
  45.         $dataCartones[] = fnCarton($list,$numbers);
  46.     }
  47.     return $dataCartones;  
  48. };
  49. $car =getCartones();
  50. var_dump($car);