note 50956 added to control-structures.foreach
| From: | justchecking at nospamsamIam dot com | Date: | Mon, 14 Mar 2005 23:27:32 +0000 |
| Subject: | note 50956 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86441@lists.php.net to get a copy of this message | ||
is there an ampersand where there should not be before the $value in your example ...
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
?>
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50956
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50956&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50956&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50956&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50956&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50956&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50956&report=yes
Search -- http://master.php.net/manage/user-notes.php