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
开发者_如何学Go
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"
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}
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}
精彩评论