note 25263 deleted from control-structures.foreach by googleguy
| From: | googleguy@php.net | Date: | Sat, 19 Jan 2013 03:46:16 +0000 |
| Subject: | note 25263 deleted from control-structures.foreach by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193243@lists.php.net to get a copy of this message | ||
Note Submitter:
----
"Also note that foreach operates on a copy of the specified array, not the array itself,
therefore the array pointer is not modified as with the each() construct and changes to the array
element returned are not reflected in the original array."
In other words, this will work (not too expected):
<?php
foreach ($array as $array) {
// ...
}
?>
While this won't:
<?php
while (list(, $array) = each($array)) {
// ...
}
?>