Nested if-else in smarty

2.4k Views Asked by At

Hi I am a beginner and I was trying to write some nested if-else statements in smarty php. It doesn't recognize them and gives an error. I have posted my code snippet but it would be best if someone gave me an example. Thank you :D

    {if $my_value[1]==1}
       {if}{/if}   ======>here I get the error
    {elseif $my_value[1]==2}
    {else}
     {/if}
1

There are 1 best solutions below

0
brzlvch On

Try this:

{if $my_value[1] == 1}
    1
{elseif $my_value[1] == 2}
    2
{else}
    0
{/if}