tags:

views:

150

answers:

2

Hi,

So currently I have an array with smarty..

{foreach from=$_sequences key=k item=v}
  Name => {$v.menu}
  Type => {$v.type}
  Step => {$v.pri} 
  Data =>{$v.data}
{/foreach}

which gives me:


Name => Test

Type => Audio

Step => 1

Data => audio1


Name => Test2

Type => Audio

Step => 2

Data => audio2


Name => Test3

Type => Audio

Step => 3

Data => audio3


Now how would I get the data for step => 2 to echo out?

So from that foreach I only want to display "audio2"

+1  A: 

Try with

{foreach from=$_sequences.1 key=k item=v}

where 1 is your second key (I think). The best way is to assign for smarty an associative array - then you will be able to work like:

{foreach from=$_sequences.audio2 key=k item=v}
hsz
+1  A: 

Use like this, sorry the modified code

{foreach from=$_sequences key=k item=v}
     {if $v.pri == "2"}
                     Name => {$v.menu}  
                     Type => {$v.type}
                     Step => {$v.pri} 
                     Data =>{$v.data}
      {/if}
 {/foreach}
Karthik
Getting this error"PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in"
zx
Oh it's because it is {if $v.pri == "2"} not )Thank you!
zx