note 9465 added to foreach
| From: | dschultz at protonic dot com | Date: | Sun, 05 Nov 2000 05:26:15 +0000 |
| Subject: | note 9465 added to foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7401@lists.php.net to get a copy of this message | ||
As was mentioned, foreach does not modify the original array, but that's easily worked around:
foreach($arr as $key => $value)
$arr[$key] = $value+3;
This snippet will increment each element of an array by 3.
http://www.php.net/manual/control-structures.foreach.php