Search code examples
arraysdynamickeysmartysmarty2

Smarty 2: Call array with string as key


I have this array {$man_data} which is structured like

10 > 'Text 8'
14 > 'Text 12'
24 > 'Text 13'

and {$entry.client_id} returns an integer (10, 14 or 24). I can't figure out how to call $man_data with key $entry.client_id?

I tried: {$man_data.{$entry.client_id}}, {$man_data.{entry.client_id}}, {$man_data.$entry.client_id}... any suggestions?


Solution

  • Have you tried:

    {$man_data[$entry.client_id]}