Ray C Ray C - 1 month ago 5
Smarty Question

Smarty. User variable as Object

I want to use smarty variable as the object key, but I can not make it working.

{$phrases['promote_no_{$type}_public_ready']}


$phrases
is the array, and
$type
is string variable.
But it does not work as expected.

When I use

{$phrases['promote_no_iphone_public_ready']}


it works,

But

{$phrases['promote_no_{$type}_public_ready']}


with the
$type
assigned "iphone", does not work.

Any idea?

Answer

All.

I have changed quote to double quote and it works. So when I used following:

{$phrases["promote_no_{$type}_public_ready"]}

it works like charm.

Thank you.

Comments