TWIG get specific key from an array

here is what i’ve put in my Symfony session

$this->session->set('teams', [
            'team_1' => ['MyTeamNameA' => ['player-1' => $safe['team-1-player-1'], 'player-2' => $safe['team-1-player-2'], 'player-3' => $safe['team-1-player-3'], 'player-4' => $safe['team-1-player-4'], 'points' => 0]],
            'team_2' => ['MyTeamNameB' => ['player-1' => $safe['team-2-player-1'], 'player-2' => $safe['team-2-player-2'], 'player-3' => $safe['team-2-player-3'], 'player-4' => $safe['team-2-player-4'], 'points' => 0]],               
        ]);

And now, in my twig, i want to retrieve my team_1 name for exemple, i did this :

app.session.get('teams')['team_1']

It doesn’t work, but, if i do a dump of this last piece of code, i got this result ( upper block in blue in the picture )

My dump() result in my page

I feel that i’m close to the answer, and yet so far 🙂
Please help!

Thank you for your time,

Shog.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *