Smarty foreach
生活随笔
收集整理的這篇文章主要介紹了
Smarty foreach
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
Smarty - Manua手冊 - Chapter 7. Built-in Functions第7章 內建函數 - {foreach},{foreachelse}用于像訪問序數數組一樣訪問關聯數組
{foreach},{foreachelse}
| from | array數組 | Yes必要 | n/a | The array you are looping through 循環訪問的數組 |
| item | string字符串 | Yes必要 | n/a | The name of the variable that is the current element 當前元素的變量名 |
| key | string字符串 | No可選 | n/a | The name of the variable that is the current key 當前鍵名的變量名 |
| name | string字符 | No可選 | n/a | The name of the foreach loop for accessing foreach properties 用于訪問foreach屬性的foreach循環的名稱 |
- from和item是必要屬性
- {foreach}循環的name可以是任何字母,數組,下劃線的組合,參考PHP變量。
- {foreach}循環可以嵌套,嵌套的{foreach}的名稱應當互不相同。
-
The?from?attribute, usually an array of values, determines the number of times?{foreach}?will loop.
- from屬性通常是值數組,被用于判斷{foreach}的循環次數。
-
{foreachelse}?is executed when there are no values in the?from?variable.
- 在from變量中沒有值時,將執行{foreachelse}。
-
{foreach}循環也有自身屬性的變量,可以通過{$smarty.foreach.name.property}訪問,其中"name"是name屬性。
-
{foreach}?properties are?index,?iteration,?first,?last,?show,?total.
- {foreach}屬性有index, iteration, first, last, show, total.
-
轉載于:https://my.oschina.net/u/162418/blog/122833
總結
以上是生活随笔為你收集整理的Smarty foreach的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 超级计算机排名
- 下一篇: window7下nginx配置文件详解