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
The use of foreach is often used in PHP, and if you use foreach, you must use an array. So in this article, we talk about the array, and we're talking about foreach.
foreach has two kinds of syntax:
First: Iterate over the given array statement
Foreach is often used in PHP, and arrays must be used to use foreach. Therefore, in this article, we talk about arrays and foreach. Foreach is often used in PHP, and arrays must be used to use foreach. Therefore, in this article, we talk about
The use of foreach is often used in PHP, and it is necessary to use a foreach array. So, in this article, we're talking about arrays while we talk about foreach.
foreach has two types of syntax:
The first: Iterate over the given array statement
The foreach basic syntax is as follows:
FOREACH ($array _variable as $value)
{
[Code to execute]
}
Or
FOREACH ($array _variable as $key => $value)
{
[Code to execute]
}
In both cases, multiple [code executions] will be executed equal to the number
The code is as follows: {code...} the final output result is as follows: {code...} question: why does the Get address character appear before the last key value? The code is as follows:
$a = [1, 2, 3];foreach($a as $key => &$value) { $value = 5;}
The code is as follows:
$a = [1, 2, 3];foreach($a as $key => &$value) { $value = 5;}var_dump($a);
The final output results are as follows:
array(3) { [0]=> int(5) [1]=> int(5) [2]=> &int(5) }
Question: Why do I get an address character before
This article describes the use and examples of foreach in PHP, details the use of foreach, and the interested partners can refer to it.
The use of foreach is often used in PHP, and it is necessary to use a foreach array. So, in this article, we're
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.