How to iterate through variables?
Posted: Sun Apr 29, 2012 12:23 pm
OK - tricky to explain....
Compiling hockey stats and I want to figure what player got the game winning goal for that game.
Example: Final score is (Home)5 - (Away)3. The game winning goal is the 4th goal scored by the Home team. That is the goal that put them ahead of the Away team.
I have a set of variables ($h_goal_1, $h_goal_2, $h_goal_3, $h_goal_4, and $h_goal_5). So the variable $h_goal_4 would be the game winner's ID.
Here is the code I have so far:
This will return a value (in this example) of 4.
What I can't figure out is how to step through the variables to get to that $h_goal_4, or how to select that particular variable and return its value.
I am sure I am having a brain fart and the answer is probably obvious, but can anyone help me muddle through it?
Compiling hockey stats and I want to figure what player got the game winning goal for that game.
Example: Final score is (Home)5 - (Away)3. The game winning goal is the 4th goal scored by the Home team. That is the goal that put them ahead of the Away team.
I have a set of variables ($h_goal_1, $h_goal_2, $h_goal_3, $h_goal_4, and $h_goal_5). So the variable $h_goal_4 would be the game winner's ID.
Here is the code I have so far:
Code: Select all
if($home_score > $away_score){
if($home_score - $away_score == 1){
$h_gwg = $home_score;
}else{
$h_gwg = $home_score - $away_score - 1;
}
}
What I can't figure out is how to step through the variables to get to that $h_goal_4, or how to select that particular variable and return its value.
I am sure I am having a brain fart and the answer is probably obvious, but can anyone help me muddle through it?