mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Add note about foreach operating on a copy of the array, not the array itself.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@27451 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
018b3e8f5a
commit
4fc9f1307b
1 changed files with 20 additions and 7 deletions
|
@ -457,13 +457,26 @@ foreach(array_expression as $key => $value) statement
|
|||
element's key will be assigned to the variable
|
||||
<literal>$key</literal> on each loop.
|
||||
</simpara>
|
||||
<simpara>
|
||||
When <literal>foreach</literal> first starts executing, the
|
||||
internal array pointer is automatically reset to the first element
|
||||
of the array. This means that you do not need to call
|
||||
<function>reset</function> before a <literal>foreach</literal>
|
||||
loop.
|
||||
</simpara>
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
When <literal>foreach</literal> first starts executing, the
|
||||
internal array pointer is automatically reset to the first element
|
||||
of the array. This means that you do not need to call
|
||||
<function>reset</function> before a <literal>foreach</literal>
|
||||
loop.
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Also note that <literal>foreach</literal> operates on a copy of
|
||||
the specified array, not the array itself, therefore the array
|
||||
pointer is not modified like with the each construct.
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
<para>
|
||||
You may have noticed that the following are functionally
|
||||
identical:
|
||||
|
|
Loading…
Reference in a new issue