#47702 [Fbk->Opn]: foreach (array(..) as &$value)
ID: 47702
User updated by: jidanni at jidanni dot org
Reported By: jidanni at jidanni dot org
-Status: Feedback
+Status: Open
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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)