Created
June 29, 2021 14:36
-
-
Save jeffersonchaves/0468c5baa1465377750c29b18cfe7efe to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$numeroDaMega = []; | |
$numerosDaMegaOrdenados = []; | |
$todosDiferentes = true; | |
$contador = 0; | |
do { | |
$todosDiferentes = true; | |
$numeroDaMega[$contador] = mt_rand(1, 60); | |
foreach ($numeroDaMega as $numero => $value) { | |
if ($numeroDaMega[$contador] == $numeroDaMega[$numero] && $contador != $numero) { | |
$todosDiferentes = false; | |
} | |
} | |
if ($todosDiferentes) | |
$contador++; | |
} while ($contador < 6); | |
$numerosDaMegaOrdenados = $numeroDaMega; | |
sort($numerosDaMegaOrdenados); | |
echo "Os números sorteados na mega são: "; | |
foreach ($numerosDaMegaOrdenados as $numero => $value) { | |
echo "$numerosDaMegaOrdenados[$numero] "; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment