The idea is to get all the possible combinations I can play on a 6/49 lottery.
For the first 2 numbers it works. When, I add the conditions for the third number it says: Undefined variable: b. I don’t understand why. I use echo there to check if the program is working.
Here is the code.
for ($i=1 ; $i<50 ; $i++)
{
$a=$i;
for ($j=1 ; $j<50 ; $j++)
{
if ($i!=$j)
{
$b=$j;
}
for ($k=1 ; $k<50 ; $k++)
{
if ($k!=$j && $k!=$i)
{
$c=$k;
echo "$a $b $c<br>";
}
}
}
}
On the first iteration
$i == $j, so$bis never initialized. You can fix it by extending theifto cover the inner loops: