#47702 [Opn->Csd]: foreach (array(..) as &$value)
ID: 47702
Updated by: fa@php.net
Reported By: jidanni at jidanni dot org
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: fa
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2009-03-18 20:30:03] jidanni at jidanni dot org
Yes, an example is worth a thousand words.
And even use something like
foreach(array($bla['a']['b']['c']) as $x){if(4==$x){$x=...}else...
where we even just have one member, and use foreach to make our
program more readable, but ... just ... can't.
------------------------------------------------------------------------
[2009-03-18 07:24:23] philip@php.net
It already contains this:
"This is possible only if iterated array can be referenced (i.e. is
variable)."
Do you feel this is unclear? Maybe cleaning up the grammar here is the
answer?
------------------------------------------------------------------------
[2009-03-18 06:14:38] jidanni at jidanni dot org
Description:
------------
In php-doc/html/control-structures.foreach.html
be sure to please mention that you can do
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
and
foreach (array(1, 2, 3, 4) as $value) {
$value = $value * 2;
}
but not
foreach (array(1, 2, 3, 4) as &$value) {
$value = $value * 2;
}
!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47702&edit=1
Thread (4 messages)