<?php
function apostar($qtdDeDezenas, $qtdDeApostas, $numMaximoDezena){
$apostas = [];
for ($i = 1; $i <= $qtdDeApostas; $i++) {
$dezenas = [];
for ($j = 1; $j <= $qtdDeDezenas; $j++) {
while (count($dezenas) < $qtdDeDezenas) { $dezenaGerada = str_pad(rand(0, $numMaximoDezena), 2, 0, STR_PAD_LEFT
); if (!in_array($dezenaGerada, $dezenas)) { $dezenas[] = $dezenaGerada;
}
}
}
sort($dezenas, SORT_NUMERIC
); // ordernar da dezena menor para maior $apostas[]['dezenas'] = $dezenas;
}
return $apostas;
}
$qtdDeDezenas = 6;
$qtdDeApostas = 15;
$numMaximoDezena = 60;
$apostas = apostar($qtdDeDezenas, $qtdDeApostas, $numMaximoDezena);
echo "<pre>";
echo "<pre>";
PD9waHAKZnVuY3Rpb24gYXBvc3RhcigkcXRkRGVEZXplbmFzLCAkcXRkRGVBcG9zdGFzLCAkbnVtTWF4aW1vRGV6ZW5hKXsKICAgICRhcG9zdGFzID0gW107CiAgICBmb3IgKCRpID0gMTsgJGkgPD0gJHF0ZERlQXBvc3RhczsgJGkrKykgewogICAgICAgICRkZXplbmFzID0gW107CiAgICAgICAgZm9yICgkaiA9IDE7ICRqIDw9ICRxdGREZURlemVuYXM7ICRqKyspIHsKICAgICAgICAgICAgd2hpbGUgKGNvdW50KCRkZXplbmFzKSA8ICRxdGREZURlemVuYXMpIHsKICAgICAgICAgICAgICAgICRkZXplbmFHZXJhZGEgPSBzdHJfcGFkKHJhbmQoMCwgJG51bU1heGltb0RlemVuYSksIDIsIDAsIFNUUl9QQURfTEVGVCk7CiAgICAgICAgICAgICAgICBpZiAoIWluX2FycmF5KCRkZXplbmFHZXJhZGEsICRkZXplbmFzKSkgewogICAgICAgICAgICAgICAgICAgICRkZXplbmFzW10gPSAkZGV6ZW5hR2VyYWRhOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBzb3J0KCRkZXplbmFzLCBTT1JUX05VTUVSSUMpOyAvLyBvcmRlcm5hciBkYSBkZXplbmEgbWVub3IgcGFyYSBtYWlvcgogICAgICAgICRhcG9zdGFzW11bJ2RlemVuYXMnXSA9ICRkZXplbmFzOwogICAgfQoKICAgIHJldHVybiAkYXBvc3RhczsKfQoKJHF0ZERlRGV6ZW5hcyA9IDY7CiRxdGREZUFwb3N0YXMgPSAxNTsKJG51bU1heGltb0RlemVuYSA9IDYwOwoKJGFwb3N0YXMgPSBhcG9zdGFyKCRxdGREZURlemVuYXMsICRxdGREZUFwb3N0YXMsICRudW1NYXhpbW9EZXplbmEpOwoKZWNobyAiPHByZT4iOwpwcmludF9yKCRhcG9zdGFzKTsKZWNobyAiPHByZT4iOw==