// In PHP:
$array = new array( 'key1' => 'val1' , 'key2' => 'val2' );
$smarty->assign('someAssignedArray' , $array );
// In SMARTY:
{foreach from=$someAssignedArray key=keyOfItem item=itemValue}
The key of this item is: {$keyOfItem}<br>
The value of this item is: {$itemValue}<br>
{/foreach}
As you can see, we have to have defined array first. Example above shows custom keyed array, but this array can also
have standarized default keys like 0,1,2,3,4 etc. The first step is to assign our array to SMARTY variables,
because SMARTY doesn't have access to global PHP scope in nice way. So we must define a custom name for this variable -in
example above i named it 'someAssignedArray'. So, the array wich in PHP exeist as $array, will exist in smarty as $someAssignedArray.
Now, you can write a foreach loop in your tpl file. The basic atribute of SMARTY foreach tag is from. This attribute says, from wich array you want to pick up all items for iteration. Remeber that this variable must have a dollar sign at begining.
Second required parameter in this loop construction is item. Item refers to name of variable, wich will have a value from array inside the loop. Key attribute works in the same way - it will contains key for item value in single loop iteration. There is some important thing - remeber that you create a new SMARTY varaibles here, so do not use dollar sign.
Inside the foreach loop, you can access your array item value and key by varaible names you specified as foreach tag attributes, this time begininnig with a dollar sign.
Of course, if yours item value is an array, nothings stop you to provide a nested foreach loop, with new key and value variables. This is useful thing.
If you want to print your array in fastest way, only for debug etc. you can try to use print_r function in your SMARTY tpl file. I wrote some nice tutorial about using print_r in SMARTY, so check itd.
If you want to provide additional filtering when iterating over items, see my tutorial about modifiers here.
This is the first time i am reading your post and admire that you posted article which gives users lot of information regarding particular topic. Thanks for this share. Indian IT Outsourcing company | Offshore Software Development Company
ReplyDeleteGood Explnation :)
ReplyDeletehave read your blog its very attractive and impressive. I like it your blog.
ReplyDeletePHP 7 Training in chennai | PHP 7 Training Course
PHP 7 Training in chennai | Online PHP 7 Course
elazığ
ReplyDeletebilecik
kilis
sakarya
yozgat
2QQCİ2
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
J4RO
denizli evden eve nakliyat
ReplyDeletekars evden eve nakliyat
çorum evden eve nakliyat
kars evden eve nakliyat
malatya evden eve nakliyat
VXMH4U
4D19B
ReplyDeleteRize Evden Eve Nakliyat
order pharmacy steroids
Karabük Evden Eve Nakliyat
https://steroidsbuy.net/steroids/
Çanakkale Evden Eve Nakliyat
masteron
Konya Evden Eve Nakliyat
İstanbul Evden Eve Nakliyat
Silivri Duşa Kabin Tamiri
D4775
ReplyDeleteGümüşhane Şehirler Arası Nakliyat
Çerkezköy Yol Yardım
Ünye Çekici
Urfa Şehir İçi Nakliyat
Gate io Güvenilir mi
Ankara Boya Ustası
Kırklareli Şehir İçi Nakliyat
Hatay Evden Eve Nakliyat
Çerkezköy Mutfak Dolabı
FD9F8
ReplyDeleteÜnye Çekici
Kilis Lojistik
Eryaman Boya Ustası
Ünye Marangoz
Antalya Şehir İçi Nakliyat
Uşak Evden Eve Nakliyat
Hakkari Parça Eşya Taşıma
Kayseri Şehirler Arası Nakliyat
İstanbul Parça Eşya Taşıma
6B418
ReplyDeleteSui Coin Hangi Borsada
Altındağ Boya Ustası
Hatay Lojistik
Loop Network Coin Hangi Borsada
Maraş Şehir İçi Nakliyat
Raca Coin Hangi Borsada
İzmir Parça Eşya Taşıma
Muş Şehir İçi Nakliyat
Van Evden Eve Nakliyat
D5603
ReplyDeleteen iyi görüntülü sohbet uygulamaları
bursa kızlarla rastgele sohbet
burdur telefonda canlı sohbet
görüntülü sohbet kızlarla
sinop görüntülü sohbet kadınlarla
balıkesir yabancı görüntülü sohbet siteleri
chat sohbet
konya görüntülü sohbet ücretsiz
zonguldak parasız sohbet
44DE1
ReplyDeletesohbet uygulamaları
kocaeli bedava sohbet uygulamaları
kırıkkale kadınlarla sohbet et
izmir sohbet sitesi
burdur canli sohbet chat
giresun canlı görüntülü sohbet
sakarya mobil sohbet siteleri
yalova nanytoo sohbet
sinop sohbet odaları
B1C38
ReplyDeleteBinance Sahibi Kim
Telegram Görüntüleme Hilesi
Coin Para Kazanma
Soundcloud Dinlenme Satın Al
Binance Yaş Sınırı
Binance Borsası Güvenilir mi
Tumblr Beğeni Satın Al
Onlyfans Beğeni Hilesi
Binance Referans Kodu
1F97F
ReplyDeleteReferans Kimliği Nedir
Pi Network Coin Hangi Borsada
Twitter Retweet Hilesi
Expanse Coin Hangi Borsada
Lunc Coin Hangi Borsada
Nexa Coin Hangi Borsada
Shinja Coin Hangi Borsada
Bitcoin Hesap Açma
Cate Coin Hangi Borsada