foreach,foreachelse function

foreach, foreachelse function

Usage:

foreach is used to process simple arrays ( The elements in the array are of the same type), and its format is much simpler than section. The disadvantage is that it can only handle simple arrays.
foreach must be used in pairs with /foreach and must be specified from and item attributes.
name Attributes can be specified arbitrarily (a combination of letters, numbers and underscores).
foreach can be nested, but the name of the foreach in the nest must be unique.
The from attribute (usually an array) determines the number of loops.
foreachelse statement in from It is executed when the variable has no value.

test.php:

$smarty->assign('custid', array(1000 ,1001,1002));

test.html:

##{foreach from=$custid item=curr_id}id: {$curr_id}

{/foreach}

Output:

微信图片_20180313094534.png


Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!