vrana Sat Aug 7 06:06:24 2004 EDT
Modified files:
/phpdoc/en/language references.xml
Log:
References and foreach (bug #24118)
http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.35&r2=1.36&ty=u
Index: phpdoc/en/language/references.xml
diff -u phpdoc/en/language/references.xml:1.35 phpdoc/en/language/references.xml:1.36
--- phpdoc/en/language/references.xml:1.35 Fri Aug 6 17:45:13 2004
+++ phpdoc/en/language/references.xml Sat Aug 7 06:06:24 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.35 $ -->
+<!-- $Revision: 1.36 $ -->
<chapter id="language.references">
<title>References Explained</title>
@@ -117,6 +117,28 @@
to <literal>$var</literal> only changes the local variable's reference.
</para>
</warning>
+ <note>
+ <para>
+ If you assign a value to variable with references in the <link
+ linkend="control-structures.foreach">foreach</link> statement,
+ references are modified too.
+ <example>
+ <title>References and foreach statement</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$ref = 0;
+$row =& $ref;
+foreach (array(1, 2, 3) as $row) {
+ // do something
+}
+echo $ref; // 3 - last element of the iterated array
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </note>
<warning>
<para>
Complex arrays are sometimes rather copied than referenced. Thus following