note 31455 modified in control-structures.foreach by vrana
| From: | vrana@php.net | Date: | Thu, 05 Aug 2004 18:11:37 +0000 |
| Subject: | note 31455 modified in control-structures.foreach by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74054@lists.php.net to get a copy of this message | ||
[Ed Note: You can also use array_keys() so that you don't have to have the $value_copy
variable --alindeman at php.net]
I use the following to modify the original values of the array:
<?php
foreach ($array as $key=>$value_copy)
{
$value =& $array[$key];
// ...
$value = 'New Value';
}
?>
--was--
[Ed Note: You can also use array_keys() so that you don't have to have the $value_copy
variable --alindeman at php.net]
I use the following to modify the original values of the array:
foreach ($array as $key=>$value_copy)
{
$value =& $array[$key];
...
$value = 'New Value';
}
http://php.net/manual/en/control-structures.foreach.php