I have an object, that I would like to interact with dynamically. I would like to rename the game1_team1 in:
$default_value = $individual_match->field_match_game1_team1[0]['value'];
to be game1_team2, game2_team1, game2_team2, game3_team1, etc. Based on the loop they are in.
I have tried:
$dynamic = 'field_match_game'.$i.'_team'.$j;
$default_value = $individual_match->$dynamic[0]['value'];
but it returns
Fatal error: Cannot use string offset as an array
Update: Based on Saul's answer, I modified the code to:
$default_value = $individual_match->{'field_match_game'.$i.'_team'.$j}[0]['value'];
which got rid of the Fatal error, but doesn't return a value.