Smarty foreach Detailed description
For the knowledge of Smarty foreach, here is a detailed explanation of its function and usage.
Smarty {foreach} is used to iterate through an associative array like iterating over a numeric index array, unlike
{Foreach}, {foreachelse}
{Foreach} is used to cyclically access an associated array like a digital index array. It is different from the {Section} That can only access the numeric index array, the syntax of {foreach} is much simpler than that of
foreach ($arr as & $value) {echo ' value: '. $value. 'foreach ($arr as $value) {echo ' value: '. $value. '?>Output Result:Value:oneValue:two
The first foreach with & does not change the contents of the array:Instead of the last loop, $value
This example describes the PHP template engine smarty built-in function Foreach,foreachelse usage. Share to everyone for your reference, specific as follows:
In the Smarty template, you can use foreach to repeat a block. And in the template, you
{Foreach} and {foreachelse} are used to access the associated array like the sequential number array.Attribute NameFrom: The array for loop accessItem: variable name of the current elementKey: The variable name of the current key name.Name: name of
This article mainly introduces the usage of the PHP template engine Smarty built-in functions foreach and foreachelse, and analyzes the functions and usage skills of foreach and foreachelse Based on the instance form, for more information about the
Arrays or objects in php can all have for, foreach, while, and listeach loops out, and smarty also has this method. otherwise, php's array object data, smarty does not know how to display it. The usage of for, foreach, and while in php is a habit.
Reading and writing Extensible Markup Language (XML) in PHP may seem a bit scary. In fact, XML and all of its related technologies can be scary, but reading and writing XML in PHP is not necessarily a scary task. First, you need to learn a little
PHP template engine Smarty built-in functions foreach, foreachelse Usage Analysis, smartyforeachelse
This article describes the usage of the PHP template engine Smarty built-in functions foreach and foreachelse. We will share this with you for your
Foreach: In PHP, how does the result of the foreach loop explain the output principle? : In PHP, how does the result of the foreach loop explain the principle of the output result? The code is as follows:;} foreach ($ arras $ value) {echoValue:. $
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.