Querendo fazer o seguinte (aprendizado) - gerar números de 1 a 60 (tipo mega sena) e que eles não podem ser igual ao outro, cheguei a esta lógica que não funciona, alguém poderia me dar alguma alternativa?
<?php
$num1 = rand (1,60) != ($num2.$num3.$num4.$num5.$num6);
echo ($num1) ."<br>";
$num2 = rand (1,60) !=($num1.$num3.$num4.$num5.$num6);
echo ($num2)."<br>";
$num3 = rand (1,60) !=($num1.$num2.$num4.$num5.$num6);
echo ($num3) ."<br>";
$num4 = rand (1,60) !=($num1.$num2.$num3.$num5.$num6);
echo ($num4) ."<br>";
$num5 = rand (1,60) !=($num1.$num2.$num3.$num4.$num6);
echo ($num5) ."<br>";
$num6 = rand (1,60) !=($num1.$num2.$num3.$num4.$num5);
echo ($num6) ."<br>";
?>
se executar vai dar isso:
Notice: Undefined variable: num2 in C:\xampp\htdocs\mega\index.php on line 3
Notice: Undefined variable: num3 in C:\xampp\htdocs\mega\index.php on line 3
Notice: Undefined variable: num4 in C:\xampp\htdocs\mega\index.php on line 3
Notice: Undefined variable: num5 in C:\xampp\htdocs\mega\index.php on line 3
Notice: Undefined variable: num6 in C:\xampp\htdocs\mega\index.php on line 3
1
Notice: Undefined variable: num3 in C:\xampp\htdocs\mega\index.php on line 6
Notice: Undefined variable: num4 in C:\xampp\htdocs\mega\index.php on line 6
Notice: Undefined variable: num5 in C:\xampp\htdocs\mega\index.php on line 6
Notice: Undefined variable: num6 in C:\xampp\htdocs\mega\index.php on line 6
1
Notice: Undefined variable: num4 in C:\xampp\htdocs\mega\index.php on line 10
Notice: Undefined variable: num5 in C:\xampp\htdocs\mega\index.php on line 10
Notice: Undefined variable: num6 in C:\xampp\htdocs\mega\index.php on line 10
1
Notice: Undefined variable: num5 in C:\xampp\htdocs\mega\index.php on line 14
Notice: Undefined variable: num6 in C:\xampp\htdocs\mega\index.php on line 14
1
Notice: Undefined variable: num6 in C:\xampp\htdocs\mega\index.php on line 17
1
1