Hello, I always get good help here and I'm lost.. did a bit of searching ans still couldn't get my code working.
I need to increment 2 variables: $i and $n
I have an array with: "Games," "username," "nextGame" and "winner"
This is my code:
<?php
foreach($games_2 as $element) {
$i=0;
$i2=$i++;
$n=8;
$n2=++$n; // also tried $n2=$n++;
if ($element['game'] >= $i2) {
echo ' <br>user: ' . $element[username];
echo ' <br>nextGame: ' . $element[nextGame];
echo ' <br>winner: ' . $element[winner];
echo ' <br>n: ' . $n2;
}
}
?>
I get the following output:
user: jay
nextGame: 9
winner: d
n: 9
user: jay
nextGame: 9
winner: a
n: 9
user: jay
nextGame: 10
winner: e
n: 9
user: jay
nextGame: 10
winner: g
n: 9
user: jay
nextGame: 11
winner: i
n: 9
$i2 is clearly incrementing and if I change to $i=3 it starts the echos with game 4 -- just like I want.
the problem is I need $n2 to increment after each game lasted (that will become the number for the winner's next game. So that winner "d" next game is game 9 and "winner a" next game is game 10 and "winner