#47702 [Opn->Fbk]: foreach (array(..) as &$value)

From: Date: Wed, 18 Mar 2009 07:24:23 +0000
Subject: #47702 [Opn->Fbk]: foreach (array(..) as &$value)
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1999@lists.php.net to get a copy of this message
 ID:          47702
 Updated by:  philip@php.net
 Reported By: jidanni at jidanni dot org
-Status:      Open
+Status:      Feedback
 Bug Type:    Documentation problem
 PHP Version: Irrelevant
 New Comment:

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?


Previous Comments:
------------------------------------------------------------------------

[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)

« previous php.doc.bugs (#1999) next »