开发者

Echo certain value from smarty array

开发者 https://www.devze.com 2022-12-28 08:50 出处:网络
So currently I have an array with smarty.. {foreach from=$_sequences key=k item=v} Name => {$v.menu}

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}
0

精彩评论

暂无评论...
验证码 换一张
取 消